I\'d like to perform the logic in the \"onClick\" through the event listener in jS but it only seems to run once? I have the class in all four but I can\'t figure out why it
Look at the documentation for querySelector
:
querySelector() returns the first Element within the document that matches the specified selector, or group of selectors.
If you want to match more than one element, you'll need to use querySelectorAll
and, because it doesn't return a single element loop over the result.
Alternatively, you could use event delegation.