I am converting a piece of code from jQuery to ChocolateChip UI, and this piece of code is stumping me as ChocolateChip UI doesn't support ':visible' for its implementation of is()
if (interactive && block.is(':visible')) {
block.fadeOut(250, function() {
block.html(newContent);
block.fadeIn(750);
});
showHighlight($("#character_text"));
}
The error I get is:
Uncaught SyntaxError: Failed to execute query: ':visible' is not a valid selector.
Two questions:
- How can I emulate
is(':visible')
using plain JavaScript? - How can I extend ChocolateChip UI's
is()
to handle:visible
?
:visible
is an extension by jQuery. So you might run into the same issue with other selectors. jQuery actually does a couple of things to determine whether an element is visible, which is explained in the documentation: api.jquery.com/visible-selector.visibility
rule set but is visible nonetheless.