skip to Main Content
  • Can anyone help to solve this issue I can’t get what wrong with code !!!!
  1. This one is javascript code

  2. Html code

  3. Error shows in console

2

Answers


  1. .querySelector(".drum") selects the first element with class "drum" so the {i} is useless, use querySelectorAll.

    Login or Signup to reply.
  2. As it mentioned in this post: Why should I not upload images of code/data/errors?
    , you should not upload image of your code. You should prefer embed your code with code tag when you ask question on stackoverflow.
    In this way, people can answer you more easily.

    In your case your using bad javascript function, you should use querySelectorAll in place of querySelector if you want to select all your button that have the drum class.

    querySelector select and return the first match of the condition as it said in the documentation: https://developer.mozilla.org/fr/docs/Web/API/Document/querySelector

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search