+ 1
JavaScript not working
For some reason, the functions to call HTML elements doesn't work, I compared to another codes, and seems to be equal, so I doesn't know why is not working :/ https://code.sololearn.com/WcpqtGnIWhxY/?ref=app
4 Answers
+ 5
window.onload = function() {
var app = document.getElementById("app");
console.log(app);
};
You need to wrap the code in an onload function so that it is run after the DOM is created. SL injects the JS and CSS tabs into the head of the html page before the body section and DOM is created.
+ 3
It's okay
+ 1
Thus is because you get a null object when you call for that element
+ 1
I wrapped the code inside the 'window.onload' function and worked fine, thank guys!