-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathdemo1.html
37 lines (35 loc) · 1001 Bytes
/
demo1.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href="loader.css" rel="stylesheet">
</head>
<body>
<div id="loader" class="loader">
<div class="progress">
<div class="progress-bar progress-bar-striped">
<div class="progress-value"></div>
</div>
</div>
</div>
</body>
<script src="jquery.js"></script>
<script>
var $bar = $('#loader').find('.progress-bar');
var $value = $bar.find('.progress-value');
var Task = function (index, duration) {
setTimeout(function () {
var p = (index / 4 * 100).toFixed(0) + '%';
$bar.css('width',p);
$value.text(p);
console.log('第' + index + '个异步任务执行完毕');
}, duration);
};
//模拟四个同时发起的异步任务
var task1 = new Task(1, 1000);
var task2 = new Task(2, 3000);
var task3 = new Task(3, 5000);
var task4 = new Task(4, 7000);
</script>
</html>