JS error help
Hi, I'm looking for javascript help with this code here, this is the 2nd day that I reopen the project and I'm getting this error, and after the first day I tried to put the code for the .minute into its own if/else statement and it seemed like it fixed it, but the error has returned and I can't figure out why
1 Reply
you probably have to add
defer
to your script tag. If you include your JS in your <head>
, the code can run before the DOM is ready and querySelector
won't work. If you change <script src="./main.js">
to <script src="./main.js" defer>
, the browser knows you want to wait to run the javascript until after the DOM is available.