W3School TIY
编辑您的代码:
<html> <head> <script type="text/javascript"> function timedText() { var t1=setTimeout("document.getElementById('txt').value='2 秒'",2000) var t2=setTimeout("document.getElementById('txt').value='4 秒'",4000) var t3=setTimeout("document.getElementById('txt').value='6 秒'",6000) } </script> </head> <body> <form> <input type="button" value="显示计时的文本" onClick="timedText()"> <input type="text" id="txt"> </form> <p>点击上面的按钮。输入框会显示出已经逝去的时间(2、4、6 秒)。</p> </body> </html>
查看结果: