开发者

how do i display the first hidden div with a specific class with jQuery?

So i have this situation ....

<div class="nested_fields"></div>
<div class="nested_fields" style="display: none;"></div>
<div class="nested_fields"></div>
<div class="nested_fields"></div>
<div class="nested_fields" style="display: none;"></div>
<div class="nested_fields" style="display: none;"></div>
<div class="nested_fields" style="display: none;"></div>

I want to display show the first nested_fields div that开发者_C百科 is not hidden...so in the above situation it would be the second div with Jquery


$(".nested_fields:hidden").first().show();

or as $(".nested_fields") returns an array of objects you can also do:

$(".nested_fields:hidden")[0].show();

or using only selectors:

 $(".nested_fields:hidden:first").show();


try this

$('.nested_fields:hidden:first')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜