JQuery latency plug-in doTimeout, jquerydotimeout

Source: Internet
Author: User

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!

  1. <Script type = "text/javascript" src = "http://banu.blog.163.com/blog/jquery.JS"> </script>

  2. <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 (){
.....
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.