• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • jQuery.dequeue()

    在匹配的元素上执行队列中的下一个函数。

    jQuery.dequeue(element[, queueName ])
    • element类型: Element。一个用于移除和执行列队的DOM元素。
    • queueName类型: String。一个含有队列名的字符串。默认是fx,标准的动画队列。

    注意这是一个底层的方法,你应该用.dequeue()代替。

    .dequeue()被调用的时候,列队中的下一个函数将从这个列队中被移除,然后再执行。这个函数应当在内部直接或间接调用 jQuery.dequeue(),以便队列得以继续执行下去。

    例子

    使用 jQuery.dequeue()来结束一个自定义队列函数,以便能够让队列继续运行下去。

    <!DOCTYPE html>
    <html>
    <head>
      <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://www.lanmper.cn/static/js/jquery-3.5.0.js"></script>
    </head>
    <body>
      <button>Start</button>  <div></div>
    <script>$("button").click(function () {
      $("div").animate({left:'+=200px'}, 2000);
      $("div").animate({top:'0px'}, 600);
      $("div").queue(function () {
        $(this).toggleClass("red");
         $.dequeue( this );
              });
      $("div").animate({left:'10px', top:'30px'}, 700);
    });</script>
     
    </body>
    </html>
    

    上篇:jQuery.queue()

    下篇:jQuery.contains()