Jquery queue and native imitation of its implementation method sharing _ jquery

Source: Internet
Author: User
Queue and dequeue in jquery are a group of useful methods, which are especially useful for a series of functions that require running in order. Special functions such as animate animation, ajax, and timeout are used to display or operate the function queue executed on matching elements in the queue () method.

The process of queue and dequeue is as follows:

Use queue to add functions to the queue (usually a Function Array)
Use dequeue to retrieve the first function in the function array, and execute (use shift () to retrieve and execute)
This means that when dequeue is executed again, another function is obtained. It also means that if dequeue is not executed, the next function in the queue will never be executed.

If you execute the animation Method on an element, jQuery also adds it to the function queue named fx. To execute animations for Multiple Elements in sequence, you must manually set the queue.

In one example, we need to move two p values to the left in sequence:

The Code is as follows:


P 1


P 2


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.