8-3 计时器setInterval()中如何解决分钟数和秒数小于10的问题?大家看下面的代码哪有问题
<!Doctype HTML>
<Html>
<head>
<title>设置计时器</title>
<meta charset="utf-8">
</head>
<script>
function clock()
{
var mtime;
var time=new Date(); //创建当前日期
mtime=time.getHours()+":"+time.getMinutes()+":"+time.getSeconds();
if(time.getMinutes()<10 or time.getSeconds()<10)
{
mtime=time.getHours()+":"+"0"+time.getMinutes()+":"+"0"+time.getSeconds();
}
document.getElementById('clock').value=mtime;
}
var int=setInterval(clock,1000)
</script>
<body>
<input type="text" id="clock" onclick="clock()" size="50">
</body>
</Html>