平常这类需求在挪动端比较罕见,就是经由过程手机注册账号嘛,轻易。
http://jsbin.com/vagocaqitu/edit?html,css,js,output
贴了个jsbin的代码片断,发明没有预览。。。
为啥只能用jsfiddle的呢?速率太慢了吧
https://jsfiddle.net/6zr4Lb5p/embedded/result,html,css,js/
javascript
var getCode = document.getElementById('getCode'); var wait = 60; function time(btn){ if (wait===0) { btn.removeAttribute("disabled"); btn.innerHTML = "猎取验证码"; wait = 60; }else{ btn.setAttribute("disabled",true); btn.innerHTML = wait + "秒后重试"; wait--; setTimeout(function(){ time(btn); },1000); } } getCode.onclick = function(){ time(this); };