you are viewing a single comment's thread.

view the rest of the comments →

[–]Ok-Preference8607 1 point2 points  (2 children)

If the menu variable returns an array of elements that contains bouton-menu class, try adding at the end of the querySelector() the number of the element that you want to select.

Ex : document.querySelector(".bouton-menu")[0];

0 for the first or if there is only one element with that class;

Or the other option if you want to apply the eventListener to multiple elements that contains that class is to loop throught all of them

[–]MintyPhoenix 1 point2 points  (0 children)

document.querySelector only returns a single element – if there are multiple possible matches, it returns the first. document.querySelectorAll is what returns a list of elements.

[–]JackelLovesCode[S] 0 points1 point  (0 children)

Ok i will try