我有JavaScript代码,下面的行有问题.
if ((hr==20)) document.write("Good Night"); document.getElementById('Night).style.display=''
Run Code Online (Sandbox Code Playgroud)
错误
Uncaught TypeError: Cannot read property 'style' of null at Column 69
Run Code Online (Sandbox Code Playgroud)
我的div标签详细信息是:
<div id="Night" style="display: none;">
<img src="Img/night.png" style="position: fixed; top: 0px; left: 5%; height: auto; width: 100%; z-index: -2147483640;">
<img src="Img/moon.gif" style="position: fixed; top: 0px; left: 5%; height: 100%; width: auto; z-index: -2147483639;"></div>
Run Code Online (Sandbox Code Playgroud)
完整的JavaScript:
<script language="JavaScript">
<!--
document.write("<dl><dd>")
day = new Date()
hr = day.getHours()
if ((hr==1)||(hr==2)||(hr==3)||(hr==4) || (hr==5)) document.write("Should not you be sleeping?")
if ((hr==6) || (hr==7) || (hr==8) || (hr==9) …Run Code Online (Sandbox Code Playgroud) javascript ×1