jquery 60s倒计时
程序员文章站
2022-05-06 10:32:40
前端开发中经常用到的发送按钮倒计时,每次都是重写,挺麻烦的,记录一下,以后直接来复制代码 ......
前端开发中经常用到的发送按钮倒计时,每次都是重写,挺麻烦的,记录一下,以后直接来复制代码
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport"> <title>60s倒计时</title> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> </head> <body> <input type="button" value="邮箱验证码" onclick="sendVerificationCode(this)" /> <script type="text/javascript"> //发送验证码按钮的60s倒计时 var countdown = 60; function sendVerificationCode(obj) { if(countdown == 0) { obj.removeAttribute("disabled"); obj.value = "重新获取"; countdown = 60; return; } else { obj.setAttribute("disabled", true); obj.value = "重新(" + countdown + ")"; countdown--; } setTimeout(function() { sendVerificationCode(obj) }, 1000) } </script> </body> </html>
上一篇: 用 js 实现博客园的 “回到顶部” 功能——简易实用~~~
下一篇: 爱上泡妞这门艺术
推荐阅读
-
jQuery实现判断控件是否显示的方法
-
jQuery Validate让普通按钮触发表单验证的方法
-
JavaScript/jQuery、HTML、CSS 构建 Web IM 远程及时聊天通信程序_jquery
-
jQuery关键词说明插件cluetip使用指南_jquery
-
求助,Jquery ajax在yii里的url问题,急
-
jQuery中index()方法用法实例教程
-
jQuery性能优化的28个建议
-
JQuery 学习技巧总结_jquery
-
jQuery基于ajax实现带动画效果无刷新柱状图投票代码_jquery
-
jquery click([data],fn)使用方法实例介绍_jquery