<!DOCTYPE html> <html> <head> <title>发送验证码</title> </head> <body> 手机号:<input type="text" name="mobile" value="" id="mobile"> 验证码:<input type="text" name="mobile" value=""> <input type="button" name="submit" value="验证码" id="sendCode"> </body> </html> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $(‘#sendCode‘).click(function(){ var count = 60; // 发送频率/秒 var countdown1 = setInterval(function(){ $(‘#sendCode‘).attr(‘disabled‘,true).css({‘color‘:‘#b5adad‘}); $(‘#sendCode‘).val(‘验证码‘+count+‘s‘); if(count == 0){ $(‘#sendCode‘).val(‘验证码‘).removeAttr(‘disabled‘).css({‘color‘:‘#27d6df‘}); clearInterval(countdown1); } count--; },1000); }); }); </script>
按钮倒计时
时间: 2024-10-21 23:20:23