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.