Bind a click event to a div block generated on the fly using jquery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:bind

Description

Bind a click event to a div block generated on the fly using jquery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script> 
  <script type="text/javascript">
    $(window).on('load', function() {

$(document).on('click', ".mootoo", function() {
    console.log("clicked");
});/* ww w  .  ja  v a  2  s  . co  m*/

$('body').append('<div class="hi">test</div>');
    });

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

Related Tutorials