Play a beep sound on button click
You could use an audio tag like this:
<audio id="audio" src="http://www.soundjay.com/button/beep-07.wav" autoplay="false" ></audio> <a onclick="playSound();"> Play</a> <script> function playSound() { var sound = document.getElementById("audio"); sound.play(); } </script>
Here is a Plunker
This works fine
function playSound () { document.getElementById('play').play();}
<audio id="play" src="http://www.soundjay.com/button/beep-07.wav"></audio><button onclick="playSound()">Play</button>
Admitting you already have something like <div id='btn'>Click to play!</div>
in your html, you could do it as simple as:
$('#btn').click( () => new Audio('mp3/audio.mp3').play() );
This is the best IMO because it allow riffle clicking on the button (which is not possible in other answers at the time) and is a one liner.