代码编辑器:
x
1
<script>
2
function timedText(){
3
var x=document.getElementById('txt');
4
var t1=setTimeout(function(){x.value="2 秒"},2000);
5
var t2=setTimeout(function(){x.value="4 秒"},4000);
6
var t3=setTimeout(function(){x.value="6 秒"},6000);
7
}
8
</script>
9
<form>
10
<input type="button" value="显示文本时间!" onclick="timedText()" />
11
<input type="text" id="txt" />
12
</form>
13
<p>点击上面的按钮,输出的文本将告诉你2秒,4秒,6 秒已经过去了</p>
14
</body>
15