#!TypeError: Cannot read properties of null (reading 'value')
8 messages · Page 1 of 1 (latest)
In your index.html file, move the script tag to the bottom of the <body>
Here's the long explanation for why this matters:
Programs (for the most part) read code line by line top to bottom, so what happens here is the program reads through the html file top to bottom and renders all that out to the screen, THEN reads the javascript file from top to bottom.
The reason why you want the script tag at the end of the body is because if your javascript file has something like document.getElementById(btn), you don't want the program to try to run that code before the button has been rendered to the screen. After all, how can the javascript do anything with that button if the button doesn't exist yet?
The exception to this is if you give the script tag the defer attribute and place it in the head. Doing this is basically saying to the program "I'm placing this script tag here, but don't do anything with it until you've finished rendering the html to the screen"
Thank you so much!
It solved every problem. Incredible.
👍
@slim nest ive tried doing this but it doesnt seem to work :C https://scrimba.com/scrim/co3394eb495d5d50e6d0d6bdd
In your index.js file line 11 you are looking for an html with an id of "inputField" but there is no element with that id