title: JQuery elements ignoring click() code if added to DOM after pageload
body: <p>So I have some code and I add an element to the DOM after pageload (the second link in the below example) however this newly added element ignores all functions defined for it.  So for the example below I want all links in div's with the test class to show an alert.  Works fine for the link hard coded but the one added afterwards ignores it.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;SO Test&lt;/title&gt;
          &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div class="test"&gt;
              &lt;a href="#" title="Test"&gt;Test Link&lt;/a&gt;
          &lt;/div&gt;
          &lt;script type="text/javascript"&gt;
          &lt;!--    
              $(document).ready(function() {
  
                  $("div.test a").click(function() {
                      alert("click");
                      return false;
                  });
  
                  $(document.createElement("a")).attr("href","#").text("Test Link 2").appendTo("div.test");
  
              });
          --&gt;
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><em>EDIT</em>: Is the only solution to abstract it away with a jQuery plugin?</p>