Dequeue () method usage instance in jquery _jquery

Source: Internet
Author: User

This example describes the use of the Dequeue () method in jquery. Share to everyone for your reference. The specific analysis is as follows:

This function can remove a queue function from the top end of the queue and execute it.
It is recommended that you study with the queue () function.

Syntax structure:

Copy Code code as follows:
$ (selector). Dequeue (QueueName)

parameter list:

Parameters Describe
QueueName Optional. The name of the queue.
The default is "FX", the animation queue.

Instance code:

Copy Code code as follows:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "Author" content= "http://www.jb51.net/"/>
<title>dequeue () function-cloud-dwelling community </title>
<style type= "Text/css" >
Div
{
margin:3px;
width:50px;
Position:absolute;
height:50px;
left:10px;
top:30px;
Background-color:yellow;
}
Div.red
{
background-color:red;
}
</style>
<script type= "Text/javascript" src= "Mytest/jquery/jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ ("div"). Animate ({left: ' +=200px '}, 2000);
$ ("div"). Animate ({top: ' 0px '}, 600);
$ ("div"). Queue (function () {
$ (this). Toggleclass ("Red");
$ (this). Dequeue ();
});
$ ("div"). Animate ({left: ' 10px ', Top: ' 30px '}, 700);
});
})
</script>
<body>
<button> Start </button>
<div></div>
</body>

Note: After you run the editor, press F5 to refresh the page to see the demo.

In the above code, the Dequeue () function can remove $ ("div") from the top end of the queue after the $ (this). Toggleclass ("Red") is executed. Animate ({left: ' 10px ', Top: ' 30px '}, 700), That is, perform this animate animation.

I hope this article will help you with your jquery programming.

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.