Check if at least one element is visible

html, jquery

Solution

You can use :visible with class selector to check if the element is visible. Use the class selector and if visible element count is greater then zero then it means atleast one element is visible.

Live Demo

if($('.the_class:visible').length)
{

}

Problem

I've a set of elements with the same class: ``` <div class="the_class"></div> <div class="the_class"></div> <div class="the_class"></div> ``` With jQuery, I want to check if at least one of these elements is shown. Something like: ``` if ($('.the_class').theFunction()) { ... } ``` What can I use?

Original source