, :
$.fn.hoverDelay = function(handlerIn, handlerOut, delay) {
if(delay === undefined) delay = 400;
var timer;
this.hover(function(eventObject) {
clearTimeout(timer);
handlerIn.apply(this,eventObject);
}, function(eventObject) {
timer = setTimeout(handlerOut.bind(this, eventObject), delay);
});
};
It works the same as a normal one $.hover, except that there is a delay of 400 ms before the mouse event is fired (which is canceled if you move the mouse backward during this timeframe).
source
share