<script src="http://code.jquery.com/jquery-latest.js"></script> <input type="button" onclick="setclock($(this),10);" value="获取验证码"> <script> function setclock(dom,value,text) { value=arguments[1]||60; text=arguments[2]||"s后可重发验证码"; dom.attr("disabled","disabled"); if(!dom.attr("data-clock")) { dom.attr("data-dvalue",dom.val()); value--; dom.attr("data-clock",value); dom.val(value+text); }else { var thisValue=parseInt(dom.attr("data-clock"))-1; dom.attr("data-clock",thisValue); dom.val(thisValue+text); } if(parseInt(dom.attr("data-clock"))>0) { setTimeout(function(){setclock(dom,value,text)},1000); }else { dom.removeAttr("disabled"); dom.removeAttr("data-clock"); dom.val(dom.attr("data-dvalue")); } } </script>