1

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!

dedaumiersmith
  • 337
  • 4
  • 14

2 Answers2

2

You can use the :visible pseudo selector:

$("li.class:visible").each(function() {
    // get information from span, like ...
    $("span", this).text();
})
eisbehr
  • 12,243
  • 7
  • 38
  • 63
1

Something like this:

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

        });
    });
Depzor
  • 1,126
  • 1
  • 12
  • 21