这个 出列 是jQuery中的一个内置方法,用于从队列中删除下一个函数,然后执行该函数。在一个队列中,将有一个等待运行dequeue()的多个函数,用于从队列中删除顶层函数并执行该函数。 语法:
null
$(selector).dequeue(name);
参数: 它接受一个参数“name”,该参数指定队列的名称。 返回值: 它返回执行给定top函数的选定元素。
< 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 > </ 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 > |
输出: 在点击“点击开始”按钮之前-
点击“点击开始”按钮后-
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END