Getting document is not defined , from document.getElementById

后端 未结 3 543
一生所求
一生所求 2020-12-10 23:09

I am learning JavaScript and I am using Atom (Text Editor). On my HTML file I got only this:




    

        
3条回答
  •  囚心锁ツ
    2020-12-10 23:38

    You have hit some menu option or key combination which is trying to execute the JS file using Node.js.

    Your code, however, is designed to run, embedded in a web page, using the APIs supplied by web browsers.

    Web browsers, under those circumstances, will provide a document object. Node.js will not.

    You need to open the HTML document in a web browser. The open in browser extension might be useful.

    You can see any error reports using the Developer Tools that every major browser supplies.

    (NB: The first error you will then encounter is explained by this question and answer).

提交回复
热议问题