开发者

getting hidden elements

开发者 https://www.devze.com 2022-12-31 21:34 出处:网络
Say I have the following unordered list <ul class=\"container\"> <li class=\"item\" style=\"display: none;\">first item</li>

Say I have the following unordered list

<ul class="container">
  <li class="item" style="display: none;">first item</li>
  <li class="item">second item</li>
  <li class="item">third item</li>
  <li class="item">forth item</li>
</ul>

how can I carry out a task only if all the items in the con开发者_JAVA百科tainer are hidden?

regards...


You can use the :visible selector to select the visible elements only. You can use the length property to check if there is zero or more. If it equals to zero, then all elements are hidden.

if ($('.container .item:visible').length == 0) {
    // All is hidden.
}
0

精彩评论

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

关注公众号