Alex
Alex

Reputation: 249

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

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...
});

Upvotes: 2

Views: 1841

Answers (0)

Related Questions