慕粉1888
2016-06-15 13:47
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
setInterval(clock,1000)
function clock(){
var time=new Date();
var week=new Array("星期日","星期一","星期二","星期三","星期四");
attime=time.getFullYear()+"年"+time.getMonth()+"月"+time.getDate()+"日"+" "+week[time.getDay()]+time.getHours()+"时:"+time.getMinutes()+"分:"+time.getSeconds()+"秒";
document.getElementById("clock").value = attime;
}
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
</form>
</body>
</html>
少了分号; 请注意分号 ; 整个是一个整体
加个;
少个分号,转义字符都要加分号
JavaScript进阶篇
468060 学习 · 21891 问题
相似问题