例子:10秒后同意按钮可点击
<body> <div> <span id="daojishi">10</span> <input disabled="disabled" type="button" value="注册" id="anniu" /> </div> </body> <script type="text/javascript"> window.setTimeout("daojishi()",1000); //功能:倒计时减1 function daojishi() { //找到span var s = document.getElementById("daojishi"); //判断 if(parseInt(s.innerHTML)<=0) { document.getElementById("anniu").removeAttribute("disabled"); } else { //获取内容,减1之后再交给span s.innerHTML = parseInt(s.innerHTML)-1; //每隔一秒调一次该方法 window.setTimeout("daojishi()",1000); } } </script>