zl程序教程

您现在的位置是:首页 >  后端

当前栏目

setTimeout自动触发一个js的方法

JS方法自动 一个 触发 setTimeout
2023-06-13 09:15:16 时间
复制代码代码如下:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>timeout</title>
</head>
<bodyonload="countSecond()">
<inputtype="text"id="time"style="border:0px;"size="1px">
</body>
</html>
<script>
x=0
functioncountSecond()
{ x=x+1
 document.getElementById("time").value=x;
 setTimeout("countSecond()",1000)
}
</script>