ドキュメント

Core/dequeue

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Core

dequeue[name] )

Removes a queued function from the front of the queue and executes it.
Arguments:
name (Optional)String
The queue name (fx by default)
Examples:

Use dequeue to end a custom queue function which allows the queue to keep going.

    $("button").click(function () {
      $("div").animate({left:'+=200px'}, 2000);
      $("div").animate({top:'0px'}, 600);
      $("div").queue(function () {
        $(this).toggleClass("red");
         $(this).dequeue();
              });
      $("div").animate({left:'10px', top:'30px'}, 700);
    });

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    
    $("button").click(function () {
      $("div").animate({left:'+=200px'}, 2000);
      $("div").animate({top:'0px'}, 600);
      $("div").queue(function () {
        $(this).toggleClass("red");
         $(this).dequeue();
              });
      $("div").animate({left:'10px', top:'30px'}, 700);
    });

  });
  </script>
  <style>
  div { margin:3px; width:50px; position:absolute;
        height:50px; left:10px; top:30px; 
        background-color:yellow; }
  div.red { background-color:red; }
  </style>
</head>
<body>
  <button>Start</button>
  <div></div>
</body>
</html>

NameType