所以我试图创建一个每日消息。分区代码
<div class="motd" id="shadowbox">
<h4 class="rainbow_text_animated" style="text-align: center;" >Message of the Day</h4>
<p id="MOTDText" style="text-align: center;">nil</p>
</div>
脚本
function motdupdate() {
var dailymessages = ["message1", "message2", "message3", "message4", "message5", "message6", "message7"]
var today = new Date();
if (today.getDay() == 0 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[0];
else if (today.getDay() == 1 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[1];
else if (today.getDay() == 2 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[2];
else if (today.getDay() == 3 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[3];
else if (today.getDay() == 4 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[4];
else if (today.getDay() == 5 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[5];
else if (today.getDay() == 6 ) document.getElementById(motd.MOTDText).innerHTML = dailymessages[6];
}
问题是,它一直给我这个错误:
index.html:59 Uncaught ReferenceError: motd is not defined
at motdupdate (index.html:59)
at <anonymous>:1:1
如何解决此问题?
守候你守候我
12345678_0001
相关分类