Home > Web Front-end > JS Tutorial > body text

Introduction to jquery delayed execution examples

巴扎黑
Release: 2017-06-30 11:44:47
Original
1190 people have browsed it

Delayed execution is quite useful in some special circumstances, and the implementation method is also very simple. This article has a good example, friends in need can refer to it, I hope it will be helpful to everyone

The code is as follows:

$(function(){ 
var $inputs = $('input[type=button]') 
.delay(500) 
.queue(function(){$(this).hide().dequeue();}) 
.delay(1500) 
.queue(function(){$(this).show();}); 
});
Copy after login

The above code makes the button in the page hide for 500 milliseconds after the page is loaded, and then display it after 1500 milliseconds.

The code is as follows:

$(function(){ 
var $inputs = $('input[type=button]') 
.delay(500) 
.queue(function(){$(this).hide().dequeue();}) 
.delay(1500) 
.show(1); 
//.queue(function(){$(this).show();}); 
});
Copy after login


The above code has the same effect as the previous code.

The code is as follows:

$(function(){ 
var $inputs = $('input[type=button]') 
.delay(500) 
.queue(function(){$(this).hide();}) 
.delay(1500) 
.show(1); 
//.queue(function(){$(this).show();}); 
});
Copy after login

The above code is also only hidden and will not be displayed again. Compared with code 2, the code in queue does not adjust dequeue. It can be seen that the queue is executed. Finally, the continued execution of the animationqueue needs to be called dequeue to continue execution (hide() in the queue here is not an animation, but the current object# There will also be problems if ## animation is executed in the queue).

The code is as follows:

$(function(){ 
var $inputs = $('input[type=button]') 
.delay(500) 
.queue(function(){$(this).hide().dequeue();}) 
.delay(1500) 
.show(); 
//.show(1); 
});
Copy after login
The above code is only hidden and will not be displayed again! ! Here show no longer specifies the duration of the animation, so the show method is no longer an animation. It can be seen that dequeue can only make subsequent methods in the animation queue execute, but cannot make the

jquery method in the non-animation queue continue to execute!

The above is the detailed content of Introduction to jquery delayed execution examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template