how to use js to play sound on button code example
Example 1: javascript play sound onclick
var audio = new Audio("soundfile.wav");
document.onclick = function() {
audio.play();
}
Example 2: how to play sound on load js
var sample = document.getElementById("foobar");
sample.play();