function timedText() { var t1=setTimeout("document.getElementById('txt').value='2 seconds!'",2000) var t2=setTimeout("document.getElementById('txt').value='4 seconds!'",4000) var t3=setTimeout("document.getElementById('txt').value='6 seconds!'",6000) }
<form> <input type="button" value="显示计时的文本!" onclick="timedText()"> <input type="text" id="txt"> </form> <p>在按钮上面点击。输入框会显示出已经流逝的 2、4、6 秒钟。</p>