I need to select one visible span in the list inside the div like this: $('#videoDesc > span:visible') or $('#videoDesc > span').filter(':visible') and it does not work in webkit
These span elements have display: none; set in style (I tested removing this and didn't change anything). In the style tag of one of them, I set its display to a string.
The display of span elements is changed using the jQuery show () and hide () functions.
If I call $('#videoDesc > span:hidden'); from the chrome console, every time I get all the elements, no matter which of them I called show() on. Similar to $('#videoDesc > span:visible'); gets an empty list: [] everytime.
In firefox and IE I do not have this problem.
I copied this from the chrome console. Since you can see the span element, VideoDesc-1 has style="display: inline;" , and it still appears when using :hidden
$('#videoDesc > span').filter(':hidden'); [<span id="videoDesc-1" style="display: inline;">β¦</span> , <span id="videoDesc-2">β¦</span> , <span id="videoDesc-3">β¦</span> , <span id="videoDesc-4">β¦</span>]
Is this some kind of webkit bug?
I managed to get around this:
$('#videoDesc > span').each(function(i, e) { if (this.style.display != 'none') { ... } });
But this bothers me as it seems like the wrong solution, the correct use :visible , but it just doesn't work on webkit
jQuery 1.6.4
source share