-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.js
More file actions
32 lines (30 loc) · 762 Bytes
/
count.js
File metadata and controls
32 lines (30 loc) · 762 Bytes
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
;(function(){
"use strict";
window.Rest = function(elem,options){
var btn = document.querySelector('#'+elem) || document.querySelector('.' + elem);
var c;
var flag = false;
var count = function(){
options.callback();
c = setInterval(function(){
btn.disabled = !flag;
options.time--;
btn.innerHTML = options.time + '秒后重新发送';
if(!options.time){
clearInterval(c);
btn.innerHTML = '发送验证码';
btn.disabled = flag;
options.time = options.time;
}
},1000);
return c;
}
if(!btn.classList.contains('press')){
if(window.addEventListener){
btn.addEventListener('click',count,false);
}else{
btn.attachEvent('onclick',count);
}
}
}
})();