Marius
@ir4MAll comments
- @Robert0362Submitted about 2 years ago@ir4MPosted about 2 years ago
Remember the script tag in index.html to refer to your script.js file, otherwise the code will not executed.
Typically you place it before the body close or at the bottom of the HTML file. If you place it in the head section the JavaScript file is executed immediately and tries to access the submit id you created in the HTML file before it is has been rendered by the DOM (Document Object Model). Maybe search for DOM to become familiar how documents are structured and the way a document is accessed and manipulated.
But you can still place the script tag in the head section, if you make sure to place your JavaScript code in the DOMContentLoaded event listener like this:
document.addEventListener('DOMContentLoaded', () => { // place your JavaScript code here and it only executes if the HTML file is fully loaded })
Note that you are currently try to access the class cardRating and cardThank by getElementById. If you change that, it should work.
0