title: JQuery: Binding events to dynamically created elements?
body: <pre><code>$(function(){
  
      $("div").click(function(){
          $(this).clone().insertAfter( $(this) ); 
      });
  
  });
  </code></pre>
  
  <p>This is a stupid little page where everytime a DIV is clicked, it generates a copy of it and it's placed right after it.</p>
  
  <p>This seems to work fine, but only for DIVs that have been hardcoded. When the DIV is cloned and then clicked, nothing happens because the event hasn't been binded to it.</p>
  
  <p>What is correct way to make this work?</p>