0
how to add a button which is used to activate an audio with JavaScript. Please
Web
3 Antworten
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>
+ 2
get audio element
then use Element.play() method
0
htm<audio src='a.mp3'></audio>
<button onclick='play()'></button>
js
function play() = {
document.querySelector('audio').play;
}