jQuery: I need something like ':visible' that works even if the parent is display=none

Posted by Master Morality on Stack Overflow See other posts from Stack Overflow or by Master Morality
Published on 2010-04-06T18:05:26Z Indexed on 2010/04/06 18:33 UTC
Read the original article Hit count: 174

Filed under:

I have a list where elements are hidden for multiple reasons, each corresponding to a css class i.e:

<style>
    .filteredOut { display: none; }
    .somethingElse { display : none; }
    ...
</style>

I want to apply alternating css classes via .filter(':even').addClass('even') but only to classes that are visible. The problem is that the parent is hidden when this happens so .filter(':visible') returns 0 elements. I need something like .filter(':visibileEventIfParentIsNot')

Further more, I'd rather not have to call a function with this in it every time I call a function that changes what's visible in a list. This may be a pipe dream, but is there a way to do this ala live() or something similar? I'm open to off the wall ideas.

© Stack Overflow or respective owner

Related posts about jQuery