


Some methods to delay execution of JS pages (organizing)_javascript skills
Generally, some methods are delayed in JS pages. You can use the following method
JQuery.delay() method introduction
http://shawphy.com/2010/11/jquery-delay.html
Usage of queue and dequeue in jQuery
http://www.jb51.net/article/25481.htm
Window.setTimeout
http://www.jb51.net/article/20741.htm
Here are some examples I use.
//Delayed query, pass an ID to query btn, Then according to its nearby FORM binding, when the control in the FORM is triggered or input, it will simulate clicking the query button after 500 milliseconds
var timeout;
function searchTrigerInit(btnId){
var $form = $("#" btnId).closest("form");
$form.find("input").not(".search_onblur").keyup(function(){
searchTriger(btnId) ;
});
$form.find("input.search_onblur").blur(function(){
searchTriger(btnId);
});
$form.find( "input[type=checkbox]").change(function(){
searchTriger(btnId);
});
$form.find("select").change(function(){
searchTriger(btnId);
});
}
function searchTriger(btnId){
if(timeout != null){
clearTimeout(timeout);
}
timeout = setTimeout("searchBtnClick('" btnId "')",500);
}
function searchBtnClick(btnId){
$("#" btnId).click();
}
Define the mask layer and close it after one minute
var hideTimeout;
function showLayerMask(){
$layerMask = $(".layerMask");
if($layerMask.length == 0){
var div = "";
var width = document.body.clientWidth;
var Height = document.body.scrollHeight;
var img = "

div = "
div = img;
div = "
var $body = $("body");
$body.prepend(div);
}
$layerMask. show();
//Cancel after 1 minute
hideTimeout = setTimeout(hideLayerMask,60000);
}
function hideLayerMask(){
if(hideTimeout != null){
clearTimeout(hideTimeout);
}
$layerMask = $(".layerMask");
$layerMask.hide();
}
Countdown
var emailTime = 30;
function nextCanDo(){
$("#mailValidateCodeBtn").val(emailTime "seconds");
emailTime -= 1;
if(emailTime ==0 ){
$("#mailValidateCodeBtn").val( "Reget verification code");
$("#mailValidateCodeBtn").attr("disabled",false);
emailTime = 30;
}else{
setTimeout("nextCanDo() ",1000);
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Implementation method: 1. Use the "sleep (delay seconds)" statement to delay the execution of the function for several seconds; 2. Use the "time_nanosleep (delay seconds, delay nanoseconds)" statement to delay the execution of the function for several seconds and nanoseconds. ;3. Use the "time_sleep_until(time()+7)" statement.

jQuery is a popular JavaScript library that provides a wealth of functions and methods, which greatly simplifies the process of writing and programming JavaScript code. In the process of using jQuery, we often encounter situations where we need to delay the execution of certain operations. This delayed execution plays an important role in actual development. This article will explore the reasons and effects of jQuery's delayed execution, and provide specific code examples. 1. Why is it necessary to delay execution? In front-end development, sometimes we need to wait

The lazy execution feature of the Go language allows programmers to execute function calls after the function returns. Its main use cases include: Lazy initialization: Delay initialization of large objects or structures until needed. Post-processing: Perform cleanup or post-processing operations after the function returns. Concurrent programming: schedule background tasks to run outside the main goroutine.

jQuery is a very popular JavaScript library that is widely used in web development. In the process of web development, we often encounter situations where we need to delay the execution of certain operations, and jQuery provides a variety of methods to achieve delayed execution. This article will explore the technical implementation of jQuery delayed execution and its advantages. 1. Use the setTimeout function to implement delayed execution. The setTimeout function is a timer function provided by JavaScript. It can be executed after a specified time interval.

Why does jQuery need delayed execution? Analysis and practice In front-end development, jQuery is a widely used JavaScript library. It simplifies DOM operations, event processing, animation effects and other functions, providing convenience for developers. However, sometimes we will find some problems, that is, under certain circumstances, jQuery needs to delay execution to achieve the desired effect. This article will analyze why jQuery requires delayed execution from both principles and practice, and provide specific code examples. one,

To master the timer function and delayed execution in JavaScript, you need specific code examples. In JavaScript, we often encounter situations where we need to execute certain codes on a scheduled basis. At this time, you need to use timer functions and delayed execution techniques to complete the task. JavaScript provides two timer functions: setInterval() and setTimeout(). The setInterval() function can repeatedly execute a piece of code at a specified time interval, while se

Golang is a widely used programming language that performs well in high-concurrency scenarios. One of its important features is the delayed execution mechanism of functions. This article will deeply explore the delayed execution mechanism of Golang functions, including the principle of delayed execution, precautions when using, etc. The principle of delayed execution The delayed execution mechanism in Golang is implemented through the defer keyword. When a function contains a defer statement, execution of the function pointed to by the statement will be deferred until the function containing the defer statement returns.

Exploration of Golang language features: Resource management and delayed execution Introduction: Resource management and garbage collection are crucial aspects when developing software. As a modern programming language, Golang provides a simple and efficient resource management mechanism through its unique features. This article will explore the resource management and delayed execution features in the Golang language, and illustrate its usage and advantages through code examples. 1. Resource Management When writing software, we often need to use some resources, such as memory, file handles, network connections, etc.
