jQuery to hide all row classes except 'row2' only when the parent class is viewContainerTop
I've been to jquery select class inside parent div and Testing objects for ancestor/descendent relationship in JavaScript or Jquery and jQuery wild card character but can't seem to fit the pieces together. Thanks.
<div id="viewContainerTop" class="top">
<div class="row1"></div>
<div class="row2"></div>
<div class="row2"></div>
开发者_如何学C<div class="row2"></div>
<div class="row3 first"></div>
<div class="row3"></div>
<div class="row3"></div>
</div>
Machting the code you posted (parent has id viewContainerTop)
$("#viewContainerTop > div:not(.row2)").hide();
Matching what you wrote (parent has class not id viewContainerTop)
$(".viewContainerTop > div:not(.row2)").hide();
$("#viewContainerTop > div:not(.row2)").hide();
精彩评论