Ata Ata - 1 year ago 86
jQuery Question

How to find first element that is hidden by JQuery

I want to show first element that is hidden by jquery. my html code is:

<li style="display:none">2</li>
<li style="display:none">3</li>
<li style="display:none">4</li>
<li style="display:none">5</li>
<li><a class="add">Add More ...</a></li>

I want to show first hidden LI, each time that "a" element was clicked.
My solution is below. but I think better way exists.

var hiddens=$(":hidden",$(this).parent().parent());
if (hiddens.length>0)

if (hiddens.length==1)


Answer Source

Just add a :first selector after you get :hidden set so you get the first element from set found by :hidden selector

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download