JavaScript TypeError: Cannot read property 'style' of null

前端 未结 6 1906
一向
一向 2020-11-30 00:25

I have JavaScript code and below line has problem.

if ((hr==20)) document.write(\"Good Night\"); document.getElementById(\'Night).style.display=\'\'
<         


        
6条回答
  •  萌比男神i
    2020-11-30 01:11

    simply I think you are missing a single quote in your code

    if ((hr==20)) document.write("Good Night"); document.getElementById('Night"here").style.display=''
    

    it should be like this

    if ((hr==20)) document.write("Good Night"); document.getElementById('Night').style.display=''
    

提交回复
热议问题