Check if the item is visible above

I want to check if an element is hanging. I get this error:

Syntax error, unrecognized expression: unsupported pseudo: hover 

when i use this code:

  $('.class').blur(function(){ if(!$(this).is(':hover')){ //element not being hovered over } }); 

I also tried this:

  $('.class').blur(function(){ if($(this+":hover").length === 0){ //element not being hovered over } }); 

this doesn't work either. Is there any other way to do this. Thank you

+5
source share
2 answers
 $(".class").mouseover(function(){ $(this).attr('checked',true); }); }); 
+1
source

jQuery has built-in functionality. See .hover () documentation

 $(".class").hover( function() { // item is being hovered over $(this).addClass('hover'); }, function() { // item is no longer being hovered over $(this).removeClass('hover'); } ); 
0
source

Source: https://habr.com/ru/post/1214943/