javascript - how to pause a audio on click a video? -


i've made jquery script pause background music on click video don't work. can me?here's javascript:

<script src="../style/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(      function(){          $("#trailer").click(              function(){                  $("#bgm").get(0).pause();                 }             )         }     ); </script> 

here's html:

<video height="340" width="864.5" id="trailer" onclick="gofullscreen('trailer');">     <source src="video.mp4" type="video/mp4"> </video> <embed src="sound.mp3" hidden="true" autostart="true" loop="true" id="bgm"></embed> 

anyway, embed mp3 can't loop too, can correct me?thks.

probably embed element not have htmlmediaelement interface includes pause() method. can use htmlaudioelement <audio> instead.

than: access audio element directly click event handler.

$("#bgm").pause(); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -