使用html+css+js实现倒计时,开启你痛苦的倒计时吧 使用html+css+js实现倒计时,开启你痛苦的倒计时吧 效果图: 这是我痛苦的倒计时,呜呜呜 好啦,再痛苦还是要分享代码,代
2021-10-30 11:57:45
187
1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <title>60秒倒计时</title> 7 </head> 8 9 <body> 10 <input type="button" id="btn" value="获取验证码" onclick="sendemail()" /> 11 </body> 12 13 </html> 14 <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 15 <script> 16 var countdown = 5 17 18 function sendemail() { 19 var obj = $("#btn") 20 settime(obj) 21 console.log(\'发送邮件\') 22 } 23 24 function settime(obj) { 25 if (countdown == 0) { 26 obj.attr(\'disabled\', false) 27 obj.val("获取验证码") 28 countdown = 5 29 return 30 } else { 31 obj.attr(\'disabled\', true) 32 obj.val("重新发送(" + countdown + ")") 33 countdown-- 34 } 35 setTimeout(function() { 36 settime(obj) 37 }, 1000) 38 } 39 </script>
15
2022-09
30
2021-10
16
2021-06