document is not declared | Sololearn: Learn to code for FREE!

+1

document is not declared

I have a problem when serching elements from HTML, in line var x = document.getElementById ("btn"); it says document is not declared why is this happening?

dom

3/22/2018 9:27:57 PM

AnsgarGM

4 Answers

New Answer

+4

window.onload = function { //your code }

+1

Try posting your whole code, but I think it’s running before the page is loaded

+1

How can I fix it?

+1

I'll try