-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path27_发送短信.html
38 lines (34 loc) · 1.1 KB
/
27_发送短信.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>发送短信</title>
<style>
</style>
</head>
<body>
手机号码:<input type="number"> <button>发送</button>
<script>
var btn = document.querySelector('button');
var time = 3; // 定义剩下的描述
var fn = function(){
if (time === 0) {
// 清除定时器和复原按钮
clearInterval(timer);
btn.disabled = false;
btn.innerHTML = '发送';
time = 3;
} else {
btn.innerHTML = '还剩下' + time + '秒';
time -= 1;
}
};
var timer = null;
btn.addEventListener('click', function(){
btn.disabled = true;
timer = setInterval(fn, 1000);
})
</script>
</body>
</head>
</html>