Make jquery :hidden and :visible selectors work
See original GitHub issueHello,
I’m probably missing something here but I can’t make jQuery :hidden
selector work.
Shouldn’t this print true
?
var jsdom = require("jsdom");
jsdom.env({
html: '<div style="display: none;" />',
scripts: [ "http://code.jquery.com/jquery-2.1.3.min.js" ],
done: function (errors, window) {
if (errors) throw errors;
console.log(window.$('div').is(':hidden')); // prints false
}
});
(jsdom version is 3.1.2)
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:13 (5 by maintainers)
Top Results From Across the Web
:visible Selector | jQuery API Documentation
This selector is the opposite of the :hidden selector. So, every element selected by :visible isn't selected by :hidden and vice versa.
Read more >css - Using jQuery to select items that have style "visibility ...
jQuery selectors :visible and :hidden only respects display:none as really hidden? NOT visibility:hidden or visibility:visible.
Read more >How to select all visible or hidden elements in a HTML page ...
In order to select all visible or hidden elements in a page using jQuery, we can use the following jQuery selectors:.
Read more >jQuery :hidden Selector - W3Schools
The :hidden selector selects hidden elements. Hidden elements are elements that are: ... Note: This selector will not work on elements with visibility:hidden....
Read more >How to Check an Element is Visible or not Using jQuery
You can use the jQuery :visible selector to check whether an element is visible in the layout or not. This selector will also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In jQuery 3 the visible pseudo selector look like this:
so I’ve used this code:
expanding a little bit on the previous workaround I ended up with this, which seems to work also in the case of nested elements
the aim is of course just to unblock
:visible
(and:hidden
) jQuery selectors