3
I would like to add an event to several different classes, example:
exemplo1.addEventListener('click', function(){
//Evento bla bla
});
exemplo2.addEventListener('click', function(){
//Evento bla bla
});
exemplo3.addEventListener('click', function(){
//Evento bla bla
});
And in order not to create duplicate code, I’d like to transform that Event in something like:
exemplo1.eventExample();
exemplo2.eventExample();
exemplo3.eventExample();
This eventExample
would have the:
addEventListener('click', function(){
//Evento bla bla
});
I apologize if I used any wrong term, I’m starting in programming!
I know I could create a function with the same event code and play inside the others Event listeners, but I wanted to learn that way.