+ 1

Can I make sound play when element is clicked?

I want to add some sound effects to my canvas

18th Mar 2021, 1:31 PM
Karak10
Karak10 - avatar
4 Réponses
+ 3
document.getElementsByTagName("canvas")[0].onclick = () => document.getElementsByTagName("audio)[0].play();
18th Mar 2021, 3:46 PM
Gordon
Gordon - avatar
+ 2
I made this: https://code.sololearn.com/WcjTk4KZJXjX/?ref=app If I have done this correctly this should clone the audio, play it and then remove it.
19th Mar 2021, 10:51 PM
Karak10
Karak10 - avatar