jQuery Time mouse is over element (Hover)
i have a hover event attached to a few links and when you go ove开发者_Go百科r it a box appears.
Is there a way that i can make the hover event only trigger if the mouse has been over the link for more then 500 ms? So currently as soon as the mouse goes over the link the box appears but i want it to only appear if the mouse has been over the box for 500 ms or longer.
var myTimeout;
$('#mylink').mouseenter(function() {
myTimeout = setTimeout(function() {
//do stuff
}, 500);
}).mouseleave(function() {
clearTimeout(myTimeout);
});
Here's a great jQuery plugin that helps you decide if the mouse movement is appropriate for initiating an action. It is called hoverIntent
精彩评论