做的稍微完善一點(diǎn)點(diǎn)。
<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<meta?name="viewport"?content="width=device-width,?initial-scale=1.0">
????<title>驗(yàn)證碼按鈕倒計(jì)時(shí)</title>
</head>
<body>
????<input?type="button"?id='send'?value="發(fā)送驗(yàn)證碼">
</body>
<script?type="text/javascript">
????var?send?=?document.getElementById('send');
????times?=?10;
????timer?=?null;
????//?console.log(send.value);
????if?(send.value?=?'發(fā)送驗(yàn)證碼')?{
????????send.onclick?=?function?()?{
????????????var?tant?=?this;
????????????//?if?(timer)?{
????????????//?????clearInterval(timer);
????????????//?????timer?=?null;
????????????//?}
????????????timer?=?setInterval(function?()?{
????????????????times--;
????????????????if?(times?<=?0)?{
????????????????????tant.setAttribute('value',?'發(fā)送驗(yàn)證碼');
????????????????????tant.disabled="";
????????????????????clearInterval(timer);
????????????????????times?=?10;
????????????????}?else?{
????????????????????tant.setAttribute('value',?times?+?'秒后重試');
????????????????}
????????????????console.log(times);
????????????},?1000);
????????????tant.setAttribute('disabled','true');
????????}
????}
</script>
</html>
2022-11-29
不錯(cuò) ,有想像
2021-10-29
很好很用心了,不錯(cuò)