+ 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?

22nd Mar 2018, 9:27 PM
AnsgarGM
AnsgarGM - avatar
4 Answers
+ 4
window.onload = function { //your code }
22nd Mar 2018, 9:37 PM
Evil Dog
Evil Dog - avatar
+ 1
Try posting your whole code, but I think it’s running before the page is loaded
22nd Mar 2018, 9:29 PM
Ariela
Ariela - avatar
+ 1
How can I fix it?
22nd Mar 2018, 9:36 PM
AnsgarGM
AnsgarGM - avatar
+ 1
I'll try
22nd Mar 2018, 9:44 PM
AnsgarGM
AnsgarGM - avatar