0
Can someone tell me what I'm doing wrong?
When I run this, all I get is an error message. https://code.sololearn.com/WhErc2PIxY8k/?ref=app
1 Resposta
+ 4
The JS tab is linked to the Html tab as it was included in the <head> part of the code... so, it's running before that the <body> content was parsing: access to the DOM ( document object model ) needs to be delayed after the required element are parsed ( and present in the DOM )...
Simplest fix, is to embed all your JS tab code in the window.onload event:
window.onload = function() {
// your code
};