jQuery.queue(element, [queueName])


version 1.3 以降

解説

DOM要素に関連付けられているキューを返します。

通常の使用では、jQueryオブジェクトに対するメソッドの queue([queueName]) の方が使いやすいです。

概念図

引数

  • element
    Element: DOM要素
  • [queueName]オプション
    String: キューの名前。指定しない場合は、デフォルトの fx キューを返します。

戻り値

  • Array<Function>: キュー内の関数の配列

例1:アニメーションが実行される毎に、キュー内の関数の数を表示します。

// アニメーション
$("#test1_run").click(function(){
    $("#block")
        .animate({height:   "0px",   opacity: 0.2}, 1500, showQueueLength)
        .animate({height:   "200px", opacity: 1.0}, 2000, showQueueLength)
        .animate({fontSize: "2.0em"}, 1500, showQueueLength)
        .animate({width:    "150px"}, 1500, showQueueLength)
        .animate({fontSize: "1.0em"}, 1500, showQueueLength)
        .animate({width:    "100px"}, 2000, showQueueLength)

    showQueueLength();
});

// キューの数を表示
function showQueueLength(){
    $("#count").text($.queue(document.getElementById("block")).length);
};



テスト1

キュー内の関数の数:0

#block