<!doctype html>
<html>
<head>
  <title>test</title>
  <meta charset="UTF-8">
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  <script>
    $(document).ready(function() {
      $('#main_body').append("<h1>Hello</h1><input id=\"but\" type=\"button\">Click");
      $("#but").on("click", function() {
        alert("bla bla");
      });
    });
  </script>
</head>
<body id="main_body"></body>
</html>Why alert doesn't work after append DOM? Should shows "bla bla" after click on it.
SOLVED
Main problem was with it:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
jquery was too old I think
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
solved problem :)
 
     
     
     
     
     
     
    