首页javascriptaudiojQuery HTML Element - 如何播放声音,并转到下一页与音频元素

jQuery HTML Element - 如何播放声音,并转到下一页与音频元素

我们想知道如何播放声音,并转到下一页与音频元素。

<!DOCTYPE html>
<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
  <button id="apDiv1">CLICK</button>
  <audio id="laugh">
    <source
      src="http://upload.wikimedia.org/wikipedia/commons/a/a2/Barking_of_a_dog.ogg"
      type="audio/ogg">
    Get a new browser!
  </audio>
  <script>
$(function(){
    function playOnClick(){
      var sound = $("#laugh")[0];     
      sound.addEventListener('ended', function() {        
         // window.location = 'page1.html';        
      }, false);
      sound.play();
   }
   $('#apDiv1').click(function(){
       playOnClick();
   });
});
</script>
</body>
</html>