JavaScript
JavaScript 计时事件
另一个简单的计时
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> </head> <head> <script> function timedText() { var x = document.getElementById('txt'); var t1 = setTimeout(function() { x.value = "2 seconds" }, 2000); var t2 = setTimeout(function() { x.value = "4 seconds" }, 4000); var t3 = setTimeout(function() { x.value = "6 seconds" }, 6000); } </script> </head> <body> <form> <input type="button" value="显示文本时间!" onclick="timedText()" /> <input type="text" id="txt" /> </form> <p>点击上面的按钮,输出的文本将告诉你2秒,4秒,6秒已经过去了。</p> </body> </html>
运行结果:
点击运行 »