<!DOCTYPE html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http- equiv="Content-Type" content="text/html; charset=utf-8" /> <head> <script language="javascript"> var a=0; var t; var timer_is_on=0; function timedCount() { document.getElementById('txt').value=a; a=a+1; t=setTimeout("timedCount()",1000); } function doTimer() { if (!timer_is_on) { timer_is_on=1; timedCount(); } } </script> </head> <body> <form> <input type="button" value="开始计时" onClick="doTimer()"> <input type="text" id="txt" value="Are you ready?"> </form> </body>