Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substitute jquery .is(:hover) pseudo element

Tags:

jquery

timeout

I use the following code-snippet on my page …

if ( $("#footer, #header").is(':visible') && && !$("#footer, #header").is(':hover') ) { 

I upgraded to the latest jQuery Version and now this .is(:hover) is no longer supported.

How do I subistute this in my code above. I googled already and found a few threads regarding this issue, but couldn't seem to find an appropriate solution for my code above.

I use this code to handle a timeout event. If my mouse is over the header or footer, I don't want the timeout to be cleared.

like image 728
matt Avatar asked May 17 '26 14:05

matt


1 Answers

You could add a class on the hover event for the elements and then check the class exists.

Toggle class on hover:

$("#footer, #header").hover(function() {
    $(this).toggleClass('hover');
});

Check for class:

if (!$("#footer, #header").hasClass('hover')) { 
     //do  your stuff
});
like image 94
haxtbh Avatar answered May 23 '26 05:05

haxtbh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!