jQueue dequeue()
时间:2020-02-23 14:46:18 来源:igfitidea点击:
jQuery deQueue()函数删除所选元素队列中等待执行的下一个函数。
为了确保进程正在运行,必须确保仅在使用queue()方法添加函数之后才调用此方法。
jQuery deQueue()
这是使用jQuery deQueue()方法的常规语法。
selector.deQueue(QueueName);
QueueName是一个可选参数,它是带有队列名称的字符串。
默认值为fx,这是标准效果队列。
jQuery dequeue()示例
以下示例演示了deQueue
方法的用法。
单击开始动画按钮将执行功能队列。
<!doctype html> <html> <head> <title>jQuery Dequeue Method</title> <style> div { height: 60px; margin: 5px; width: 60px; position: absolute; left: 10px; top: 50px; background-color: red; } div.green{ background-color: green; } </style> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> </head> <body> <button>Start Animation</button> <div></div> <script> $( "button" ).click(function() { $( "div" ) .animate({ left:"200px" }, 1500 ) .animate({ top:"0px" }, 700 ) .queue(function() { $( this ).toggleClass( "green" ).dequeue(); }) .animate({ left:"100px", top:"30px" }, 800 ); }); </script> </body> </html>
jQuery deQueue()方法从队列中删除下一个未执行的函数。
如果没有传递任何参数作为参数,则deQueue方法将从标准效果队列中删除这些功能。
jQuery出队演示
jQuerydeQueue()
方法总是与queue()方法一起使用,如果不使用,队列将不会关闭,您将得到不想要的结果。