jquery实现表单获取短信验证码代码
效果图:
代码如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jquery表单获取短信验证码代码</title> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script> $(function(){ //获取短信验证码 var validCode=true; $(".msgs").click (function () { var time=30; var code=$(this); if (validCode) { validCode=false; code.addClass("msgs1"); var t=setInterval(function () { time--; code.html(time+"秒"); if (time==0) { clearInterval(t); code.html("重新获取"); validCode=true; code.removeClass("msgs1"); } },1000) } }) }) </script> <style type="text/css"> form{margin:200px auto;width:500px;} label{font-size:14px;color:#555;line-height:40px;margin-right:10px;} input{width:212px;height:38px;border-style:none;padding:0 4px;border:1px solid #C8C8C8;margin-right:10px;outline:none;} .msgs{display:inline-block;width:104px;color:#fff;font-size:12px;border:1px solid #0697DA;text-align:center;height:30px;line-height:30px;background:#0697DA;cursor:pointer;} form .msgs1{background:#E6E6E6;color:#818080;border:1px solid #CCCCCC;} </style> </head> <body> <form> <label>验 证 码</label> <input type="text"> <span class="msgs">获取短信验证码</span> </form> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17