forked from AttackXiaoJinJin/jQueryExplain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQuery之$.queue,$.dequeue,$.Callbacks().html
61 lines (49 loc) · 1.37 KB
/
jQuery之$.queue,$.dequeue,$.Callbacks().html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery之动画</title>
</head>
<body>
<script src="jQuery.js"></script>
<div id="A" style="background-color: deeppink">这是A</div>
<script>
//以滑动方式隐藏被选元素
// $("#A").slideUp()
// //逐渐改变被选元素的不透明度,从隐藏到可见(褪色效果)
// .fadeIn()
// function showIt() {
// let length=$("#A").queue("fx").length
// console.log(length,'fx18');
// if(!!length){
// setTimeout(showIt, 100);
// }
// }
// showIt() //1 0
// 在slideUp()运行前,将slideUp、fadeIn放进queue中
// 然后依次出队并运行,只有在前一个函数运行结束后,后一个函数才能出队运行
//queue
//既是setter,也是getter
function a(next,hooks) {
console.log('a',next,hooks,'a34')
}
function b() {
console.log('b','b37')
}
//将a、b方法存在类型为type的队列里
//jQuery.fn.queue 给jQuery对象$("A")
/*setter*/
$("#A").queue('type', a)
// $("#A").queue('type', b)
//取出在type队列中的方法的集合
/*getter*/
$("#A").queue('type') //[a,b]
// $("#A").dequeue('type') //'a','a34'
// $("#A").dequeue('type') //'a','a34'
// $("#A").dequeue('type') //'b','b37'
// (function c(name) {
// console.log(name,'name54')
// })('chen')
</script>
</body>
</html>