+ 3
Why is the style method not working in .js
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.
+ 7
It because the javascript load before the JS, i think you should use window.onload
Example:
window.onload = function(){
// you code
}
+ 2
On which part of the coding
+ 2
What is wrong with the style being NULL
+ 2
myDiv is not a id