jquery12 queue() : 队列方法
<!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>
jquery12 queue() : 队列方法的更多相关文章
- jQuery源码05 (3653 , 3797) queue() : 队列方法 : 执行顺序的管理
//对外接口 jQuery.extend({ queue: function( elem, type, data ) {//入队.元素.队列名字.存进去的函数 //jQuery.queue( this ...
- stack堆栈容器、queue队列容器和priority_queue优先队列容器(常用的方法对比与总结)
stack堆栈是一个后进先出的线性表,插入和删除元素都在表的一端进行. stack堆栈的使用方法: 采用push()方法将元素入栈: 采用pop()方法将元素出栈: 采用top()方法访问栈顶元素: ...
- 8.12 day31 进程间通信 Queue队列使用 生产者消费者模型 线程理论 创建及对象属性方法 线程互斥锁 守护线程
进程补充 进程通信 要想实现进程间通信,可以用管道或者队列 队列比管道更好用(队列自带管道和锁) 管道和队列的共同特点:数据只有一份,取完就没了 无法重复获取用一份数据 队列特点:先进先出 堆栈特点: ...
- python并发编程-进程间通信-Queue队列使用-生产者消费者模型-线程理论-创建及对象属性方法-线程互斥锁-守护线程-02
目录 进程补充 进程通信前言 Queue队列的基本使用 通过Queue队列实现进程间通信(IPC机制) 生产者消费者模型 以做包子买包子为例实现当包子卖完了停止消费行为 线程 什么是线程 为什么要有线 ...
- C++ 标准模板库STL 队列 queue 使用方法与应用介绍
C++ 标准模板库STL 队列 queue 使用方法与应用介绍 queue queue模板类的定义在<queue>头文件中. 与stack模板类很相似,queue模板类也需要两个模板参数, ...
- C#基础---Queue(队列)的应用
Queue队列,特性先进先出. 在一些项目中我们会遇到对一些数据的Check,如果数据不符合条件将会把不通过的信息返回到界面.但是对于有的数据可能会Check很多条件,如果一个数据一旦很多条件不 ...
- atitit. java queue 队列体系and自定义基于数据库的队列总结o7t
atitit. java queue 队列体系and自定义基于数据库的队列总结o7t 1. 阻塞队列和非阻塞队列 1 2. java.util.Queue接口, 1 3. ConcurrentLink ...
- C#部分---特殊集合:stack栈集合、queue队列集合、哈希表集合。
1.stack栈集合:又名 干草堆集合 栈集合 特点:(1)一个一个赋值 一个一个取值(2)先进后出实例化 初始化 Stack st = new Stack(); //添加元素用push st.Pus ...
- Python自动化运维之16、线程、进程、协程、queue队列
一.线程 1.什么是线程 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位. 一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行 ...
随机推荐
- centos7 安装swftools Apache_OpenOffice
centos7 yum -y install wget wget http://www.swftools.org/swftools-0.9.2.tar.gz tar -xf swftools-.tar ...
- Linux环境下源码安装PostgreSQL
1.下载PostgreSQL源码包,并保存到Linux操作系统的一个目录下 2.解压PostgreSQL源码包 :tar zxvf postgresql-9.2.4.tar.gz 或 tar jxvf ...
- 《剑指offer》二叉树的镜像
一.题目描述 操作给定的二叉树,将其变换为源二叉树的镜像. 二.输入描述 二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 三.输出描述 镜像二叉树 8 / \ 10 ...
- 使用U盘安装win8(win8.1)系统
下载镜像 下载系统镜像,可以选32位或64位.下完后放到非系统盘(如果需要重新分区的,要先保存到移动硬盘或U盘) 使用U盘制作PE 准备一个4G以上的U盘(备份好U盘里的资料,因为刻录PE需要格式化U ...
- iview中键盘上下左右事件的方法
document.addEventListener('keydown', function(e){ var keyCode = e.keyCode; // Esc slide-up ) { e.pre ...
- BZOJ 3639: Query on a tree VII LCT_set维护子树信息
用 set 维护子树信息,细节较多. Code: #include <cstring> #include <cstdio> #include <algorithm> ...
- jquery validate验证规则重用
当多个控件验证规则相同时,如何避免冗余代码并应用相同规则呢? [1st way. addMethod+addClassRules] 场景:维护学生档案时需要维护父母.监护人.紧急联系人的身份证号码,此 ...
- 《2017全球人工智能人才白皮书》发布丨解读世界顶级AI牛人的秘密——腾讯研究院
<2017全球人工智能人才白皮书>发布丨解读世界顶级AI牛人的秘密——腾讯研究院:下载链接:http://www.tisi.org/c16 这个报告写的很好,排版布局,表格,色调,内容都值 ...
- ArcGIS api for javascript——地理编码任务-反向地理编码
描述 反向地理编码确定地图上给出点的地址.本例展示了如何通过ArcGIS JavaScript API做反向地理编码. 反向地理编码和常规的地理编码请求都使用Locator类和ArcGIS Serve ...
- LeetCode -- 最大连续乘积子序列
问题描写叙述: 给定数组,找出连续乘积最大值的子序列.比如 0,-1,-3.-2.则最大连续乘积为6= (-3) * (-2) 实现思路此题与最大连续和的子序列问题相似,也可通过找到递推公式然后用DP ...