慕先生0450854
2016-08-02 17:39
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
<input type="button" value="Start" id="start"/>
<input type="button" value="Stop" id="stop"/>
</form>
<script type="text/javascript">
var attime;
var ostart=document.getELementById('start');
var ostop=document.getELementById('stop');
var timer=null;
ostart.onclick=function start(){
clearInterval(timer);
timer=setInterval(function(){
var time=new Date();
attime=time.getHours()+":"+ time.getMinutes()+":"+ time.getSeconds();
document.getElementById("clock").value = attime;
},1000);
}
</script>
</body>
</html>
document.getElementById('id');你的l大写了
JavaScript进阶篇
468789 学习 · 22582 问题
相似问题
回答 3