Created
January 30, 2009 08:23
-
-
Save higeorange/54973 to your computer and use it in GitHub Desktop.
jQuery MouseOverDelay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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