Answers for "click on button audio sound play"

0

play audio on button click html

var sound = new Audio("file.wav");

button.addEventListener('click',()=>{
	sound.currentTime = 0;
	sound.play();
});
Posted by: Guest on August-05-2021
0

click play sound

<!doctype html>
<html>
  <head>
    <title>Audio</title>
  </head>
  <body>

    <script>
      function play() {
        var audio = document.getElementById("audio");
        audio.play();
      }
    </script>

    <input type="button" value="PLAY" onclick="play()">
    <audio id="audio" src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3"></audio>

  </body>
</html>
 Run code snippet
Posted by: Guest on December-07-2021

Code answers related to "click on button audio sound play"

Browse Popular Code Answers by Language