-
Notifications
You must be signed in to change notification settings - Fork 0
/
numChange.html
46 lines (39 loc) · 1.01 KB
/
numChange.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="num">
</div>
<div class="num1">
</div>
<div class="num2">
</div>
<div class="num3">
</div>
</body>
<script>
function Num(val, el) {
this.Num = val;
this.overNum = (this.Num - Math.ceil(Math.random(1) * 20));
this.num = document.querySelector(el);
var time = setInterval(function() {
this.overNum += 1;
this.num.innerText = this.overNum;
if (this.overNum >= this.Num) {
clearInterval(time);
this.overNum = this.Num;
this.num.innerText = this.overNum;
}
}.bind(this), 30)
}
new Num(200, '.num');
new Num(200, '.num1');
new Num(200, '.num2');
new Num(200, '.num3');
</script>
</html>