Answer the question
In order to leave comments, you need to log in
How to apply a function to all divs with id/class?
It is necessary that when clicking, moving and releasing on the div, different functions occurred.
There are a lot of divs with the same id/class and you need to have the same functions for each.
tried but addEventListener only works with 1 div
Answer the question
In order to leave comments, you need to log in
function handler(e) {
// ...
}
document.addEventListener('event-type', event => {
if (event.target.classList.contains('my-class')) {
handler(event);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question