Tuesday, July 24, 2018

javascript - document.getElementbyId() returning null

Answer


Answer






In the code at the line marked as //Error in comments. I get Javascript error saying: "Cannot read property style of 'null'". I have no idea what it is not able to find the object. I have thought and tried everything. Please help. Here is the code:










Facebook login








Answer



You are executing your javascript code BEFORE the

was actually created.



Also note that you did not close your

with a corresponding
.




So move your javascript code to a part below your HTML. Or execute it after the page finished loading. If you are using JQuery you can do:





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...