-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjq.html
127 lines (95 loc) · 2.58 KB
/
jq.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="aaa">
0000
<div class="div">
111
<div class="div2">
2222
<div class="div3">
33333
</div>
</div>
<button class="div2" disabled="disabled">
2222
<div class="div3">
33333
</div>
</button>
<button class="div2" disabled="disabled">
2222
</button>
<div class="div3">
33333
</div>
</div>
</div>
<div></div>
<div id="test">
我是测试啊
<button>111</button>
<button >2222</button>
</div>
<script src="js/test/jq.js"></script>
<!--<script src="js/test/testJq.js"></script>-->
<script>
function test2(){
this.handles = {};
}
test2.prototype = {
constructor:test2,
addHandlers:function(type,func){
if(typeof this.handles[type]=="undefined"){
this.handles[type] = [];
}
this.handles[type].push(func);
},
fire:function(type,args){
if(this.handles[type] instanceof Array){
for(var i= 0,j=this.handles[type].length;i<j;i++){
this.handles[type][i](args);
}
}
},
removeAddhandlers:function(type){
if(this.handles[type] instanceof Array){
delete this.handles[type];
}
}
};
var qwe = new test2();
qwe.addHandlers('aa',function(msg){
console.log(msg);
})
qwe.removeAddhandlers('aa');
qwe.fire('aa', '我是sb啊');
function test(list,callback){
setTimeout(function () {
var task = list.shift();
task();
if(list.length>0){
setTimeout(arguments.callee, 1000);
}else{
callback();
}
}, 25);
}
var defer = $.Deferred(); //构建异步对象
setTimeout(function(){
defer.resolve( 5 );
},1000);
var filtered = defer.then(function( value ) {
console.log('刚开始', value);
});
filtered.done(function( value ) {
console.log('打印出值',value)
});
console.log('测试异步');
</script>
</body>
</html>