Giles Taylor Giles Taylor - 1 year ago 60
jQuery Question

How do I select only my list items that aren't hidden using jQuery?

A really simple question I'm sure but...

I have an unordered list, in which some amount of the list items have been slid up. I want to extract information from spans within the visible list items only, using an $.each loop.

I want to write something along these lines to access this information but I don't know what the right parameter is:

if ("li.class" *isn't hidden*) {
// get information from span

The best I can come up with is adding a class each time a list item is slid up and then removing that class when it slides back down, which I guess would be fine, but I'm suspecting jQuery already has something in place.


Answer Source

Something like this:

    $(function() {
        $('li.class:visible').each(function() {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download