1<script>
2function play() {
3 var audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3');
4 audio.play();
5}
6</script>
7<button onclick-"play();">PLAY MY AUDIO</button>
1//play audio with from html audio element:
2document.getElementById('myAudioTagID').play();
3
4//play audio with out html audio tag
5var myAudio = new Audio('my_great_song.mp3');
6myAudio.play();
1//play audio with from html audio element:
2document.getElementById('myAudioTagID').play();
3
4//play audio with out html audio tag
5var myAudio = new Audio('my_great_song.mp3');
6myAudio.play();