使用jQuery检查是否所有的div都被隐藏 [英] Use jQuery to check if all div's are hidden

查看:82
本文介绍了使用jQuery检查是否所有的div都被隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查是否所有的div与类测试是隐藏的。如果他们都隐藏,设置wrap1为隐藏。感谢。

How would I check if all the div's with class test are hidden. And if they are all hidden set wrap1 to hidden. Thanks.

<div id='wrap1'>
<div class="header">Header 1</div>
<div class='test'><a href="#">Test 1</a></div>
<div class='test'><a href="#">Test 2</a></div>
<div class='test'><a href="#">Test 3</a></div>
</div>

更新:
感谢大家的快速答复,

UPDATE: Thanks everyone for the really quick answers, I got it working. They were all very helpful.

推荐答案

您可以使用上面建议的选择器进行检查,如下所示: / p>

You can do the check as by using selector as suggested above and to it like this:

 if ( $("div.test:visible").length === 0)
      $("#wrap1").hide( );

这篇关于使用jQuery检查是否所有的div都被隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆