大家看看哪里错了,为什么控制台一直在弹 document.getElementById('time').innerText=dateStr;这行错误
<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title></title><script>setInterval(sho...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
setInterval(showTime,1000);
function showTime(){
var now = new Date();
var dateStr = "当前时间:"
+now.getFullYear()+"年"
+(now.getMonth()+1)+"月"
+now.getDate()+"日"
+now.getHours()+"时"
+now.getMinutes()+"分"
+now.getSeconds()+"秒";
document.getElementById('time').innerText=dateStr;
}
</script>
</head>
<body>
</body>
</html> 展开
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
setInterval(showTime,1000);
function showTime(){
var now = new Date();
var dateStr = "当前时间:"
+now.getFullYear()+"年"
+(now.getMonth()+1)+"月"
+now.getDate()+"日"
+now.getHours()+"时"
+now.getMinutes()+"分"
+now.getSeconds()+"秒";
document.getElementById('time').innerText=dateStr;
}
</script>
</head>
<body>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询