Javascript delay on audio play on click - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Javascript delay on audio play on click

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>  Dan Kreiger</title> 
 </head> /*from ww w .ja v  a  2  s  .  c  o m*/
 <body translate="no"> 
  <button class="but">sound here</button> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
  <script>
      $(document).ready(function() {
  var blue = new Audio("https://your file.mp3");
  $(".but").on("click", function() {
       blue.play();
  });
});
    
      </script>  
 </body>
</html>

Related Tutorials