play audio javascript
snippet in javascript

play sound javascript

user252

var audio = new Audio("folder_name/audio_file.mp3");
audio.play();

play audio in javascript

user7638

var audio = new Audio('audio_file.mp3');
audio.play();

play audio javascript

user9626


var bMusic = new Audio('welcome1.mp3')
	bMusic.play()

play a sound wiith js

user5297

var audio = new Audio('audio.mp3');
  audio.play();

javascript play audio

user3010

//play audio with from html audio element: 
document.getElementById('myAudioTagID').play();

//play audio with out html audio tag
var myAudio = new Audio('my_great_song.mp3');
myAudio.play();

play sound in javascript

user4516

<script>
function play() {
  var audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3');
  audio.play();
}
</script>
<button onclick-"play();">PLAY MY AUDIO</button>