Home > Web Front-end > JS Tutorial > Introduction to jquery delayed execution examples_jquery

Introduction to jquery delayed execution examples_jquery

WBOY
Release: 2016-05-16 17:24:48
Original
1257 people have browsed it
Copy code The code is as follows:

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

The above code makes the button in the page 500 milliseconds after the page is loaded. Hide, then show after 1500 milliseconds.
Copy code 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();});
});

The above code has the same effect as the previous code.
Copy 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();});
});

Same code as above It is only hidden and will not be displayed again. Compared with code 2, the code in queue does not call dequeue. It can be seen that after the execution of queue is completed, the continued execution of the animation queue is also stopped, and dequeue needs to be called to continue execution (here in queue hide() is not an animation, and there will be problems if the animation of the current object is executed in the queue).
Copy code The code is as follows:

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

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 jquery methods in non-animation queues continue to execute!
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