jQuery | dequeue()及其示例

这个 出列 是jQuery中的一个内置方法,用于从队列中删除下一个函数,然后执行该函数。在一个队列中,将有一个等待运行dequeue()的多个函数,用于从队列中删除顶层函数并执行该函数。 语法:

null
$(selector).dequeue(name);

参数: 它接受一个参数“name”,该参数指定队列的名称。 返回值: 它返回执行给定top函数的选定元素。

显示此函数工作的jQuery代码:
代码#1:

< html >
< head >
< style >
div {
margin: 15px 0 0 0  ;
width: 100px;
position: absolute;
height: 30px;
left: 10px;
top: 30px;
background-color: lightgreen;
text-align: center;
padding: 15px;
}
div.red {
background-color: red;
}
</ style >
< script src = " https://code.jquery.com/jquery-1.10.2.js " ></ script >
</ head >
< body >
< div >GfG!</ div >
<!-- click on this button to perform animation -->
< button >Click to start !</ button >
< script >
$( "button" ).click(function() {
<!--jQuery code to demonstrate animation with the help of dqueue method-->
$( "div" )
.animate({ left:"+=500px" }, 1000 )
.animate({ top:"0px" }, 1000 )
.queue(function() {
$(this).toggleClass("green").dequeue();
})
.animate({ left:"50px", top:"150px" }, 1000 );
});
</ script >
</ body >
</ html >


输出: 在点击“点击开始”按钮之前- 图片[1]-jQuery | dequeue()及其示例-yiteyi-C++库

点击“点击开始”按钮后- 图片[2]-jQuery | dequeue()及其示例-yiteyi-C++库

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享