var d = new Date();
var day;
switch (d.getDay()) {
case 0 :
day = "Sunday";
break;
case 1 :
day = "Monday";
break;
case 2 :
day = "Tuesday";
break;
case 3 :
day = "Wednesday";
break;
case 4 :
day = "Thursday";
break;
case 5 :
day = "Friday";
break;
default :
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is : " ;
答案 0 :(得分:-1)
添加HTML和缺少的day
,并在赋值前末尾添加
var d = new Date();
var day;
switch (d.getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
default:
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is : " + day;
<div id="demo"></div>