JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://malsup.github.io/jquery.blockUI.js"></script>
<audio id="myaudio" onended="onAudioEnded();">
<source src="http://www.dccl.org/Sounds/pchick-alarm.wav" type="audio/wav">
Your browser does not support the audio element.
</audio>
<input
type="button"
value="You cannot click me before the sound is over"
onclick="javascript:alert('congrats!')"
/>
JavaScript
$(function(){
var audio = document.getElementById("myaudio");
$.blockUI({message : "Listen to the music!" });
audio.play();
});
function onAudioEnded(){
$.unblockUI();
alert("It's over!!");
};