Search code examples
jquerycsshighlight

jquery find element with class and style display:block


I am retrieving the number of "found" elements (these elements have the .highlight class) with this simple jQuery snippet:

$(".highlight").length

But now my problem is that some elements are hidden, via style="display: none;"

Now, How can I get the number of elements highlighted AND displayed?

Something like:

$(hasClass 'highlight' AND has style 'display: block'). length ?

Solution

  • You can use :visible to get element which are visible.

    $(".highlight:visible").length