-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample88.html
44 lines (36 loc) · 1.14 KB
/
sample88.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="counter1"></div>
<div id="counter2"></div>
<script src="jquery-2.1.4.js"></script>
<script>
(function($){
$.fn.count = function(opt) {
var options = $.extend({},
$.fn.count.defaultOpts,
opt);
return this.each(
function() {
var $this = $(this);
$this.text(options.startCount + '');
var myInterval = window.setInterval(function() {
var curCount = parseFloat($this.text());
curCount++;
$this.text(curCount + '');
}, 1000);
}
);
};
})(jQuery);
$.fn.count.defaultOpts = {
startCount: 100
};
jQuery('#counter1, #counter2').count({ startCount: 150});
</script>
</body>
</html>