jQuery.dequeue()の例



Jquery Dequeue Example



jQuery.dequeue(element [、queueName])戻り値: 未定義

説明: 一致した要素のキューで次の関数を実行します。

  • 追加されたバージョン: 1.3 jQuery.dequeue(element [、queueName])

    • エレメント タイプ: エレメント キューに入れられた関数を削除して実行するためのDOM要素。
    • queueName タイプ: キューの名前を含む文字列。デフォルトはfx、標準のエフェクトキュー。

ノート: これは低レベルの方法です。おそらく使用する必要があります .dequeue() 代わりは。



いつjQuery.dequeue()が呼び出され、キュー上の次の関数がキューから削除されてから実行されます。この関数は、順番に(直接的または間接的に)原因となるはずですシーケンスを続行できるように、jQuery.dequeue()が呼び出されます。

例:

jQuery.dequeue()を使用して、キューの継続を可能にするカスタムキュー関数を終了します。



doctype html> <html lang='en'> <head> <meta charset='utf-8'> <title>jQuery.dequeue demotitle> <style> div { margin: 3px; width: 50px; position: absolute; height: 50px; left: 10px; top: 30px; background-color: yellow; } div.red { background-color: red; } style> <script src='https://code.jquery.com/jquery-3.5.0.js'>script> head> <body> <button>Startbutton> <div>div> <script> $( 'button' ).click(function() { $( 'div' ) .animate({ left: '+=200px' }, 2000 ) .animate({ top: '0px' }, 600 ) .queue(function() { $( this ).toggleClass( 'red' ); $.dequeue( this ); }) .animate({ left:'10px', top:'30px' }, 700 ); }); script> body> html>

デモ: