Skip to content

Instantly share code, notes, and snippets.

@higeorange
Created January 30, 2009 08:23
Show Gist options
  • Save higeorange/54973 to your computer and use it in GitHub Desktop.
Save higeorange/54973 to your computer and use it in GitHub Desktop.
jQuery MouseOverDelay
/*
jQuery MouseOverDelay
MIT License
Usage:
Alert 'hoge' after 5 seconds from mouseover #hoge element.
$('#hoge').mouseOverDelay(5, function() { alert('hoge') ));
*/
(function($) {
$.fn.mouseOverDelay = function(delay, callback) {
return this.each(function(){
var tid;
$(this).hover(function(){
tid = setTimeout(callback, delay * 1000);
}, function(){
clearTimeout(tid);
});
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment