<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>发送短信案例</title>
</head>
<body>
手机号码:
<input type="text" value="">
<button>发送</button>
<script>
var btn = document.querySelector('button');
var ipt = document.querySelector('input');
var time = 60;
btn.addEventListener('click',function() {
btn.disabled = true;
var times = setInterval(function() {
if (time == 0)
{
//清除定时器和复原按钮
clearInterval(times);
btn.disabled = false;
btn.innerHTML = '发送';
time = 60; //从新刷新时间
} else
{
btn.innerHTML = '还剩下' + time + '秒';
time--;
}
},1000);
});
</script>
</body>
</html>
javaScript实现短信发送案例
最新推荐文章于 2023-08-16 20:39:19 发布