Last active
August 18, 2020 13:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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