Skip to content

Instantly share code, notes, and snippets.

@antydemant
Last active August 18, 2020 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antydemant/74b00e27790e65f4555a29b73eea7bb2 to your computer and use it in GitHub Desktop.
Save antydemant/74b00e27790e65f4555a29b73eea7bb2 to your computer and use it in GitHub Desktop.
jQuery 3 pseudo class selection solution | Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: hover
//
// pseudo ':hover' is not supported by jQuery 3
//
// Works with jQuery 1.7.1
$("*").on('click', $.proxy(function() {
if ( this.$('.tooltip:hover').length > 0 ) { // jQuery 3.2.1 will trigger this -> Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: hover
console.log('Hovered!');
} else {
console.log('Where is my element!?');
}
}, this));
// It works like a charm with jQuery 3 (3.2.1)
$("*").on('click', $.proxy(function() {
var isHovered = $('.tooltip').filter(function() {
return $(this).is(":hover");
});
if ( isHovered.length > 0 ) {
console.log('Hovered!');
} else {
console.log('Where is my element!?');
}
}, this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment