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

后端 未结 3 451
名媛妹妹
名媛妹妹 2020-12-10 12:32

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 i

3条回答
  •  我在风中等你
    2020-12-10 12:44

    Simply use .length against the jQuery collection.

    var $elements = $('ul#myUlElement').children('li');
    alert($elements.length)
    

提交回复
热议问题