Giles Taylor Giles Taylor - 4 months ago 7
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:

$("li.class").each(function(){
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.

Thanks!

Answer

Something like this:

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

        });
    });
Comments