夏析
2018-08-31 22:43
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
var i;
function clock1(){
i = setInterval(function(){
var time=new Date();
document.getElementById("clock").value = time},1000);
}
</script>
</head>
<body onload="clock1()">
<form>
<input type="text" id="clock" size="50" />
<input type="button" name="stop" value="stop" onclick="clearInterval(i)">
<input type="button" name="start" value="start" onclick="clock1()">
</form>
</body>
</html>
编辑器的问题哟,放在webstorm里运行是好的
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题