How can I bind events to the appended element?
<p>I tried to show an error message using the jquery effect <code>fadeTo</code> and tried to hide the message by appending a button and using fadeout but doesn't seem to work.</p>

<p>What I did was:</p>

<pre><code>$("#sub_error")
  .fadeTo(200, 0.1, function()
  {
    $("#sub_error")
      .html(error.join("&lt;br/&gt;&lt;br/&gt;"))
      .append('&lt;br/&gt;&lt;input type="button" name="err_ok" id="err_ok" value="ok"&gt;')
      .addClass('subboxerror')
      .fadeTo(900,1);
  });

$("#err_ok").click(function() 
{
  $("#sub_error").fadeOut("slow");
});
</code></pre>

<p>What am I doing wrong, could someone help me?</p>
