子要素の id を見て div 要素をフィルタリングしようとしていますが、機能していないようで、その理由を特定できません。
html:
<div class="section-link" id="section-tooltip">
<div class="brand tp" style="display: none;"></div>
contents
</div>
<div class="section-link" id="section-tooltip">
<div class="brand garden" style="display: none;"></div>
contents
</div>
js:
function brand(string){
var brand = string;
$('.section-link').hide();
if ($(".section-link").children('.brand').hasClass(brand)) {
$(this).parent().show();
}
}
次に、Chrome ブラウザを介して次のコードを実行しています: javascript:brand("tp");
すべての div を非表示にしますが、内部に tp 要素があるものは表示しません