JQuery latency plug-in doTimeout, jquerydotimeout
In many specific applications, the event delay trigger is required. The setTimeout function is used in specific implementation, but it is still inconvenient to use. So here we introduce a jQuery plug-in doTimeout, this plug-in can achieve the same effect as setTimeout, and is easy to use. At the same time, you can forcibly execute the callback function before running timeout. Supports jQuery chained call. Use instance
I. UI front-end Framework carefully developed for five years, including files!
<Script type = "text/javascript" src = "http://banu.blog.163.com/blog/jquery.JS"> </script>
<Script type = "text/javascript" src = "http://banu.blog.163.com/blog/jquery.do-timeout.js"> </script>
Ii. HTML Section
<p id="text-input">biuuu.com</p> <form action=''> <input type="text" name="whatever"> </form>
3. UI front-end Framework carefully developed in Javascript for 5 years!
$(function(){ var default_text = $('p.textfield').text(); $('form input').keyup(function(){ $(this).doTimeout( 'typing', 250, function(){ $('#text-input').text( $(this).val() || default_text ); }); }); });
The preceding example provides a function to trigger the keyboard keyup event with a delay, and displays the currently entered characters in the DIV layer with the ID of text-input.
For specific applications, you can view the doTimeout JS library file to easily implement the personalized event delay trigger function.
You need to use jQuery to move the mouse over an element with a latency of 200 milliseconds to trigger the event, but if less than 200, canceling the trigger can also be done with JS.
$ (Function (){
$ (Target). mouseover (function (){
B = setTimeout (function () {code...}, 200 );
}). Mouseout (function (){
ClearTimeout (B)
}).
})
JQUERY latency
$ (). Hover (
Function (){
},
Function (){
SetTimeout (function2 (), 500 );
}
);
....
Function function2 (){
.....
}