Trying to get the first visible element of a list using jQuery\'s :first
and :visible
pseudo-selectors, as suggested here: https://stackoverflow.co
Try using this:
$('ul').find('li:visible:first').css('background','blue');
Currently your code is just getting the first visible li
element on the page and setting the background colour. This code selects all ul
elements then finds the first visible li
within each of them and applies the style.
Here it is working: http://jsfiddle.net/FAY9q/5/