<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-2.0.3.js"></script>
<script> jQuery.extend({
queue ------------------- push()
dequeue -------------- shift()
_queueHooks
});
jQuery.fn.extend({
queue
dequeue
delay
clearQueue
promise
}); //队列中存储的都是函数 $(function(){
function aaa(){
alert(1);
}
function bbb(){
alert(2);
}
$.queue( document , 'q1' , aaa );//q1是队列名字
$.queue( document , 'q1' , bbb );
$.queue( document , 'q1' , [aaa,bbb] );
console.log( $.queue( document , 'q1' ) );//输出队列所有函数 $.dequeue( document,'q1' ); //从头取一个,aaa()
$.dequeue( document,'q1' ); //从头取,bbb()
------------------------------------------------------------------
function aaa(){
alert(1);
}
function bbb(){
alert(2);
}
$(document).queue('q1',aaa);
$(document).queue('q1',bbb);
console.log( $(document).queue('q1') );//[aaa,bbb] $(document).dequeue('q1');//1
$(document).dequeue('q1');//2 });
//[ ]
</script>
</head> <body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ width:100px; height:100px; background:red; position:absolute;}
</style>
<script src="jquery-2.0.3.js"></script>
<script> $(function(){ $('#div1').click(function(){
//不是一起变化,先宽完了之后在高最后left,使用队列完成。
$(this).animate({width : 300},2000); setInterval
$(this).animate({height : 300},2000); setInterval
$(this).animate({left : 300},2000); setInterval
}); $('#div1').click(function(){ $(this).animate({width : 300},2000).queue(function(next){ $(this).css('height',300);
next(); //也可以写成 $(this).dequeue(); }).animate({left : 300},2000); $(this).animate({width : 300},2000,function(){//第一个animate执行完之后走回调,回调中打开一个定时器就完了,再执行第二个animate,定时器是异步操作,将会跟第二个animate一起进行。 //$(this).css('height',300);
var This = this;
var timer = setInterval(function(){
This.style.height = This.offsetHeight + 1 + 'px';
if( This.offsetHeight == 200 ){
clearInterval(timer);
}
},30); }).animate({left : 300},2000); $(this).animate({width : 300},2000).queue(function(next){ var This = this;
var timer = setInterval(function(){
This.style.height = This.offsetHeight + 1 + 'px';
if( This.offsetHeight == 200 ){
next();
clearInterval(timer);
}
},30); }).animate({left : 300},2000); });
------------------------------------------------------------- function aaa(){
alert(1);
} function bbb(){
alert(2);
} $.queue( document , 'q1' , aaa );
$.queue( document , 'q1' , bbb );
$.queue( document , 'q1' , [ccc] );//ccc是数组时候覆盖aaa,bbb
console.log( $.queue( document , 'q1') ); $.dequeue( document , 'q1' );//出队时候函数aaa要执行一次 ----------------------------------------------------------------
function aaa(){
alert(1);
} function bbb(){
alert(2);
} $(document).queue('q1',aaa);
$(document).queue('q1',bbb); console.log( $(document).queue('q1') );//查看[function, function]0:function aaa()1:function bbb() $(document).dequeue('q1');
$(document).dequeue('q1'); }); </script>
</head> <body>
<div id="div1"></div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1{ width:100px; height:100px; background:red; position:absolute;}
</style>
<script src="jquery-2.0.3.js"></script>
<script>
//delay() : 延迟队列的执行
$(function(){
$('#div1').click(function(){
$(this).animate({width : 300},2000).animate({left : 300},2000);
$(this).animate({width : 300},2000).delay(2000).animate({left : 300},2000);
//队列全部执行完之后,再去调用
$(this).promise().done(function(){
alert(123);
});
});
});
</script>
</head> <body>
<div id="div1"></div>
</body>
</html>

最新文章

  1. Dynamo分布式系统——「RWN」协议解决多备份数据如何读写来保证数据一致性,而「向量时钟」来保证当读取到多个备份数据的时候,如何判断哪些数据是最新的这种情况
  2. 驱动实现led,pwm和中断基础知识
  3. jquery blockui 遮罩
  4. 修改mysql表结构,添加一个主键索引自增字段,修改原来的主字段为普通字段
  5. iOS - Swift Range 范围
  6. zboot/xtract.c
  7. 嵌入式Qt4.7.1安装详解
  8. JSP前端总结
  9. iOS 通讯录-获取联系人属性
  10. 创建iwatch 程序选项
  11. bzoj3238--后缀自动机
  12. C++ 常见的 Undefined symbols for architecture *
  13. Session的引入以及Cookie的不足
  14. Pyhton编程(一)之第一个Pyhton程序
  15. Oracle创建表时Storage参数具体含义
  16. [jzoj]2505.【NOIP2011模拟7.29】藤原妹红
  17. 【优秀的艺术文字和图标设计软件】Art Text 3.2.3 for Mac
  18. [leetcode]Largest Rectangle in Histogram @ Python
  19. ASP.NET Core网站初探
  20. JS中数组和对象的区别

热门文章

  1. Mysql锁表
  2. Django关于图片验证码显示笔记
  3. Nginx搭建图片服务器
  4. 使用goroutine+channel和java多线程+queue队列的方式开发各有什么优缺点?
  5. c# static 常量
  6. [NOIP2016普及组]魔法阵
  7. CentOS下安装SVN服务端
  8. [Python] Read and plot data from csv file
  9. POJ2485 Highways 【MST】
  10. Android-Universal-Image-Loader 学习笔记(五)线程池分析