+ 1
How do I play audio onClick()
How do I play audio when an element is clicked on?
5 Respuestas
+ 6
var audio = new Audio(URL-for-audio-file-here);
element.onclick = function() {
audio.play();
};
+ 4
quick easy way is to simply
<audio controls src=" the audio.mp3 url here " alt="audio.mp3" ></audio>
+ 3
The url would be in quotes else it would be an error
var audio = new Audio('my-audio-link.mp3')
Jingga Sona
+ 2
oh okay!👍 thanks @lord krishna and @rowsej (signal error so i cant mention you two)
+ 1
Rowsej what if the link contain "http://"? the "//" will be converted to comment