请老师检查一下代码,谢谢

来源:5-6 编程练习

hyperse

2019-02-17 23:35:20

在慕课的网页中好像老是显示不出来结果,但是在自己电脑编辑器打开网页查看后又能看到,


<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>改变日期格式</title>

<script>

function newDate(){

var today=new Date(),

year=today.getFullYear(),

month=today.getMonth()+1,

now=today.getDate(),

week=today.getDay(),

weeks=["日","一","二","三","四","五","六"],

hour=today.getHours(),

minute=today.getMinutes(),

second=today.getSeconds();

document.write(

"今天是"+year+"年"+month+"月"+now+"日星期"+weeks[week]+"<br/>"

);

document.write(hour+":"+minute+":"+second);

}

newDate();

</script>

</head>

<body>

</body>

</html>


写回答

1回答

好帮手慕糖

2019-02-18

同学你好,实现没有问题,另,如下,在线编辑器中也是可以正常显示的哦。

http://img.mukewang.com/climg/5c6a21a600014ce105590116.jpg

祝学习愉快!

0

0 学习 · 36712 问题

查看课程