jQuery.dequeue()

jQuery.dequeue()

jQuery.dequeue( element [, queueName ] )Returns: undefined

Description: Execute the next function on the queue for the matched element.

Note: This is a low-level method, you should probably use -dequeue() instead-

When jQuery-dequeue() is called, the next function on the queue is removed from the queue, and then executed- This function should in turn (directly or indirectly) cause jQuery-dequeue() to be called, so that the sequence can continue-

Example:

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

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery.dequeue demo</title>
  <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-1.10.2.js" rel="external nofollow" ></script>
</head>
<body>
 
<button>Start</button>
<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>

Demo:

© The jQuery Foundation and other contributors
Licensed under the MIT License.
https://api.jquery.com/jQuery.dequeue

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部