Friday, June 28, 2019

html - Why can't javascript find a div that is defined below it?





This works:



  










This doesn't:



  










mybla is null at this point. argh. How can I make this work? Thanks!!!

(and yes, I want the div below the script)


Answer



Because the DOM isn't fully loaded yet. You need to put your code in an onload handler if you want it above the HTML. Like this:






No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...