Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一组具有相同类的元素:
<div class="the_class"></div> <div class="the_class"></div> <div class="the_class"></div>
使用 jQuery,我想检查是否至少显示了这些元素之一。就像是:
if ($('.the_class').theFunction()) { ... }
我可以使用什么?
您可以使用:visible和类选择器来检查元素是否可见。使用类选择器,如果可见元素计数大于零,则表示至少有一个元素可见。
现场演示
if($('.the_class:visible').length) { }