jquery mouse through (hover) event delay processing, the specific JS code is as follows:
(function ($) {
$.fn.hoverdelay = function (options) {
var defaults = {
hoverduring:200,
outduring:200,
hoverevent:function () {
$.noop ();
},
outevent:function () {
$.noop ();
}}; var sets = $.extend (Defaults,options | | {});
var hovertimer, Outtimer;
Return $ (a). each (function () {
$ (this). Hover (function () {
cleartimeout (outtimer);
Hovertimer = settimeout (sets.hoverevent, sets.hoverduring);
},function () {
cleartimeout (hovertimer);
Outtimer = settimeout (sets.outevent, sets.outduring);
});
});
}
(JQuery);
The Hoverdelay method has a total of four parameters, which means the following:
hoverduring delay time of mouse passing
outduring The time delay of mouse moving out
hoverevent Mouse Execution method
outevent mouse out of the way to execute
The purpose of this function is to allow the mouse to be separated by event and delay, and the delay and delay clearance are resolved by this method. All you have to do is set the time scale for the delay, and the corresponding mouse pass or remove event. For a Simple example , the following code:
$ ("#test"). Hoverdelay ({
hoverduring:1000,
outduring:1000,
hoverevent:function () {
$ ("#tm"). Show ();
},
outevent:function () {
$ ("#tm"). Hide ();
}
);
The following is a more concise case :
$ ("#test"). Hoverdelay ({
hoverevent:function () {
alert ("Pass me!"). ");
}
});
The implication is that the element with the ID test pops up after 200 milliseconds after the mouse passes through me! The pop-up box for the text typeface.
The above is about the jquery mouse through (hover) events of the delay to deal with all the content, I hope to help you learn.