Javascript $(document).on('click') - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:on

Description

Javascript $(document).on('click')

Demo Code

ResultView the demo in separate window

<html>
 <head></head> 
 <body> 
  <h1> hello </h1> 
  <audio id="audio"> 
   <source src="http://your mp3 file" type="audio/aac"> 
  </audio> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
  <script type="text/javascript">
function dosomething(){//  w w  w.  ja  va2  s .  c  o m
    $('body').append('document click<br />');
    document.getElementById('audio').play();};
    $(document).on('click', function(){dosomething()});

      </script>  
 </body>
</html>

Related Tutorials