Juery手册 专题
专题目录
您的位置:JS框架 > Juery手册专题 > Jquery1.7-queue(element,[queueName])
Jquery1.7-queue(element,[queueName])
作者:--    发布时间:2019-11-21

返回值:array/jqueryqueue(element,[queuename])

概述

显示或操作在匹配元素上执行的函数队列

参数

element,[queuename]element,stringv1.3

element:检查附加列队的dom元素

queuename:字符串值,包含序列的名称。默认是 fx, 标准的效果序列。

element,queuename,newqueue element,string,array v1.3

element:检查附加列队的dom元素

queuename:字符串值,包含序列的名称。默认是 fx, 标准的效果序列。

newqueue:替换当前函数列队内容的数组

element,queuename,callback()element,stringv1.3

element:检查附加列队的dom元素

queuename:字符串值,包含序列的名称。默认是 fx, 标准的效果序列。

callback():要添加进队列的函数

示例

描述:

显示队列长度

html 代码:
<style>
  div { margin:3px; width:40px; height:40px;
        position:absolute; left:0px; top:30px; 
        background:green; display:none; }
  div.newcolor { background:blue; }
  span { color:red; }
</style>
<button id="show">show length of queue</button>
<span></span>
<div></div>
jquery 代码:
$("#show").click(function () {
      var n = $("div").queue("fx");
      $("span").text("queue length is: " + n.length);
});
function runit() {
      $("div").show("slow");
      $("div").animate({left:'+=200'},2000);
      $("div").slidetoggle(1000);
      $("div").slidetoggle("fast");
      $("div").animate({left:'-=200'},1500);
      $("div").hide("slow");
      $("div").show(1200);
      $("div").slideup("normal", runit);
}
runit();

描述:

通过设定队列数组来删除动画队列

html 代码:
<style>
  div { margin:3px; width:40px; height:40px;
        position:absolute; left:0px; top:30px; 
        background:green; display:none; }
  div.newcolor { background:blue; }
  </style>

  <button id="start">start</button>
  <button id="stop">stop</button>
  <div></div>
jquery 代码:
$("#start").click(function () {
      $("div").show("slow");
      $("div").animate({left:'+=200'},5000);
      $("div").queue(function () {
          $(this).addclass("newcolor");
          $(this).dequeue();
      });
      $("div").animate({left:'-=200'},1500);
      $("div").queue(function () {
          $(this).removeclass("newcolor");
          $(this).dequeue();
      });
      $("div").slideup();
  });
  $("#stop").click(function () {
      $("div").queue("fx", []);
      $("div").stop();
  });

描述:

插入一个自定义函数 如果函数执行后要继续队列,则执行 jquery(this).dequeue();

html 代码:
<style>
  div { margin:3px; width:40px; height:40px;
        position:absolute; left:0px; top:30px; 
        background:green; display:none; }
  div.newcolor { background:blue; }
  </style>
  click here...
  <div></div>
jquery 代码:
$(document.body).click(function () {
      $("div").show("slow");
      $("div").animate({left:'+=200'},2000);
      $("div").queue(function () {
          $(this).addclass("newcolor");
          $(this).dequeue();
      });
      $("div").animate({left:'-=200'},500);
      $("div").queue(function () {
          $(this).removeclass("newcolor");
          $(this).dequeue();
      });
      $("div").slideup();
});
网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册