HTML代码:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>无标题文档</title> 6 </head> 7 8 <body> 9 <form> 10 <input type="submit" id="b1" name="b1" value="同意(10)" disabled="disabled" /></form> 11 </body> 12 </html> 13 <script> 14 15 var n=10; 16 var b=document.getElementById("b1"); 17 function bian() 18 { 19 n--; 20 if(n==0) 21 { 22 b.removeAttribute("disabled"); 23 b.value="同意"; 24 } 25 else 26 { 27 b.value="同意("+n+")"; 28 window.setTimeout("bian()",1000); 29 } 30 } 31 window.setTimeout("bian()",1000); 32 </script>
效果为: