19th Mar 2019, 11:51 PM
Gavin Macpherson
Gavin Macpherson - avatar
5 odpowiedzi
+ 3
You defined the variable while the document is not yet completely loaded, that is why it is NULL Take a look at my code: https://code.sololearn.com/Wjl7R0x9HamE/?ref=app _____________________ EDIT: Everything is inside a function to make sure it is not called before the document is loaded. A surrounding window.onload = function would be even better or a <body onload="initialize()"> where initialize is a function that creates all necessary (global) variables.
20th Mar 2019, 12:38 AM
Pete Wright
Pete Wright - avatar
+ 7
It because the javascript load before the JS, i think you should use window.onload Example: window.onload = function(){ // you code }
20th Mar 2019, 12:28 AM
Jingga Sona
Jingga Sona - avatar
+ 2
On which part of the coding
20th Mar 2019, 12:31 AM
Gavin Macpherson
Gavin Macpherson - avatar
+ 2
What is wrong with the style being NULL
20th Mar 2019, 12:33 AM
Gavin Macpherson
Gavin Macpherson - avatar
+ 2
myDiv is not a id
20th Mar 2019, 12:38 AM
Ole113
Ole113 - avatar