-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.html
55 lines (51 loc) · 1.07 KB
/
jquery.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>浏览器环境测试</title>
</head>
<body>
<div id='haha'>哈哈</div>
<button id='promise'>异步运行</button>
<script type="text/javascript">
</script>
<script type="text/javascript" src="jquery/dist/jquery.js"></script>
<script type="text/javascript">
/**
*回调函数
**/
// var callback=$.Callbacks('unique');
// function fn1(value){
// console.log(value);
// }
// callback.add(fn1);
// callback.add(function(value){
// fn1('fn1 say '+value);
// });
// callback.add(fn1);
// callback.fire('haha');
// callback.fire('oo');
function task3(name) {
var dtd = $.Deferred();
setTimeout(function() {
console.log('task3执行完毕');
dtd.resolve(name);
}, 500);
return dtd;
}
function task4(name) {
var dtd = $.Deferred();
setTimeout(function() {
console.log('task4执行完毕');
dtd.resolve(name);
}, 100);
return dtd;
}
$("#haha").click(function() {
$.when(task3('task1'), task4('task2')).done(function() {
console.log('when处理成功');
})
});
</script>
</body>
</html>