question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

:hidden and :visible selectors are not available

See original GitHub issue

The :hidden and :visible selectors are not available.

http://api.jquery.com/hidden-selector/ http://api.jquery.com/visible-selector/

Test case:

var cheerio = require('cheerio');
var $ = cheerio.load('<h1 style="display:none">Test</h1>');
console.log($("h1:hidden").length);

Error:

SyntaxError: unmatched pseudo-class :hidden

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ktrzeciaknubisacommented, Nov 9, 2016

I needed to remove :hidden elements, and so I made this piece of code which checks .css('display') value:

var cheerio = require('cheerio');
var $ = cheerio.load('<h1 style="display:none">Test Hidden</h1><h1>Test Visible</h1>');

$.root().children().filter(function(i, el) {
    var display = $(this).css('display');
    if (display === 'none')
        $(this).remove();
});

console.log($.html());
// <h1>Test Visible</h1>
1reaction
fb55commented, Jan 16, 2015

IMHO this would do more harm than good - a partial implementation would have people expecting the selector to work properly, which it never will.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between :hidden and :not(:visible) in jQuery
The :hidden selector is the opposite of the :visible selector. So, every element selected by :hidden isn't selected by :visible and vice versa....
Read more >
:visible Selector | jQuery API Documentation
So, every element selected by :visible isn't selected by :hidden and vice versa. All option elements are considered hidden, regardless of their selected...
Read more >
jQuery :visible Selector - W3Schools
The :visible selector selects every element that is currently visible. Visible elements are elements that are not: Set to display:none; Form elements with...
Read more >
How to select all visible or hidden elements in a HTML page ...
:visible Selector The visible Selector is used to select all the elements that are currently visible in the document. Syntax: $(":visible"). : ...
Read more >
How to Check an Element is Visible or not Using jQuery
This selector will also select the elements with visibility: hidden; or opacity: 0; , because they preserve space in the layout even they...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found