jquery deferred execution Instance introduction _jquery

Source: Internet
Author: User
Copy Code code as follows:

$ (function () {
var $inputs = $ (' Input[type=button] ')
. Delay (500)
. Queue (function () {$ (this). Hide (). Dequeue ();})
. Delay (1500)
. Queue (function () {$ (this). Show ();});
});

The above code lets the button in the page Hide 500 milliseconds after the page is loaded, and then displays it in 1500 milliseconds.
Copy Code code 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 effect is the same as the preceding code.
Copy Code code as follows:

$ (function () {
var $inputs = $ (' Input[type=button] ')
. Delay (500)
. Queue (function () {$ (this). Hide ();})
. Delay (1500)
. Show (1);
. Queue (function () {$ (this). Show ();});
});

The above code is also only hidden, will not be shown, compared to code 2,queue in the code does not tune Dequeue, so, after the queue execution, also suspended the animation queue to continue execution, need to invoke the dequeue to carry it down (here queue in the Hide () is not an animation , and there is a problem with animating the current object in the queue.
Copy Code code 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 shown again!! Here show no longer specifies the length of the display animation, the shows method is no longer an animation. As a result, dequeue can only allow subsequent methods in the animation queue to continue without the jquery method in the non-animated queue!

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.