JQuery - How do I count the number of elements selected by a selector?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-04-21T20:39:45Z Indexed on 2010/04/21 20:43 UTC
Read the original article Hit count: 147

Filed under:
|

I am using $().fadeOut() to fade items out in a list ( < li> < /li>). When the list is empty I wish to hide a parent object.

I plan on doing this by checking in my trigger event that fades the list if the count of the objects is 0 then hide the parent element. I can use the fadeOut callback to remove the elements if necessary.

The to the point question: How do I select li tags inside a ul and then get the total count of them using jquery?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript