再加一個(gè)按鈕star,點(diǎn)擊按鈕計(jì)時(shí)器繼續(xù)運(yùn)行怎么實(shí)現(xiàn)呢
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
function clock(){
var time=new Date(); ? ? ? ? ? ? ? ?
document.getElementById("clock").value = time;
}
var i = setInterval(clock,1000);
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" ?/>
<input type="button" value="start" onclick="setInterval(clock,1000)">
<input type="button" value="Stop" ?onclick="clearInterval(i)"/>
</form>
</body>
</html>
2020-01-15
沒(méi)用的 重新開(kāi)始根本觸發(fā)不了? 有沒(méi)有大神
2019-09-02
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
? ?function clock(){
? ? ? var time=new Date();? ? ? ? ? ? ? ? ??
? ? ? document.getElementById("clock").value = time;
? ?}
? ? var i=setInterval("clock()",1000);
? ?function begin(){
? ? ? ? i=setInterval("clock()",1000);
? ?}
? ??
</script>
</head>
<body>
? <form>
? ? <input type="text" id="clock" size="50"? />
? ? <input type="button" value="Stop" onclick="clearInterval(i)" />
? ? <input type="button" value="Begin" onclick="begin()" />
? </form>
</body>
</html>
2019-07-20
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計(jì)時(shí)器</title>
<script type="text/javascript">
?? function clock(){
????? var time=new Date();????????????? ??? ? ?
????? document.getElementById("clock").value = time;
?? }
??? var i=setInterval("clock()",100);
??? function setTime(){
??????? var er=setInterval("clock()",100);
??? }
</script>
</head>
<body>
? <form>
??? <input type="text" id="clock" size="50"? />
??? <input type="button" value="Stop" onClick="clearInterval(i)" />
??? <input type="button" value="Begin" onclick="setTime()" />
? </form>
</body>
</html>
2019-07-17
<input type="button" value="Begin" onclick="setInterval(i)" />