How to attach multiple Event Listeners to the same button in vanilla JavaScript?

1.8k Views Asked by At

Looking for the best way to have two events for same button click (vanilla javascript only please), first one should happen on touchstart the other one on the TransitionEnd.

Is this would be correct / best way to do it?

document.getElementById("btn").addEventListener('touchstart', playSound, false {
        //Play sound, sync or async - not decided yet.
});

document.getElementById("btn").addEventListener('TransitionEnd', buttonAnimation, false {
        //do an action after css animation ends, like open dialog...
});
0

There are 0 best solutions below