0

how to add a button which is used to activate an audio with JavaScript. Please

Web

24th Jun 2020, 11:39 AM
Moussa Ndoye
Moussa Ndoye - avatar
3 Respostas
0
<html> <body> <audio id="audio" src="audio.mp3 "></audio> <button onclick="play()" ></button> <script> Var audio = document.getElementById("audio").play; function play () { audio} </script> </body> </html>
6th Oct 2020, 9:38 PM
Moussa Ndoye
Moussa Ndoye - avatar
+ 2
get audio element then use Element.play() method
24th Jun 2020, 11:50 AM
Gordon
Gordon - avatar
0
htm<audio src='a.mp3'></audio> <button onclick='play()'></button> js function play() = { document.querySelector('audio').play; }
24th Jun 2020, 9:55 PM
moses
moses - avatar