<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
function clock(){
var time=new Date();
attime= "时:" + time.getHours() +" 分:"+time.getMinutes() +" 秒:"+ time.getSeconds();
document.getElementById("clock").value = attime;
}
var actTime = setInterval(clock,100);
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
</form>
</body>
</html>请问这段代码的问题在哪,为什么空格不能正常显示出来???显示出来的时 ,菜鸡求解,勿喷。。。
可以直接这样加空格, attime= "时:" + time.getHours() +" 分:"+time.getMinutes() +" 秒:"+ time.getSeconds();,至于为什么错,没搞太明白。