开发者

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

开发者 https://www.devze.com 2023-04-13 03:42 出处:网络
So i have this situation .... <div class=\"nested_fields\"></div> <div class=\"nested_fields\" style=\"display: none;\"></div>

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

精彩评论

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

关注公众号