unable to fetch the id of dynamically generated button in jquery
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9484295/jquery-click-not-working-for-dynamically-created-items">jQuery click not working for dynamically created items</a>  </p>
</blockquote>



<pre><code>        $(document).ready(function(){
            $('#btn').click(function(){

                var createInput=$("&lt;input type='button'&gt;");
                createInput.attr("id","close1");
                createInput.attr("value","close");
                $('#outer-div').append(createInput);
            });

            $("#close1").click(function(){
                alert('hi');
            });
        });


    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id='outer-div'&gt;
        &lt;input id='btn' type='button' value='click here'/&gt;
    &lt;/div&gt;
</code></pre>

<p><strong>What's wrong with the code. I am not getting the alert when i click the dynamically generated button named as close. Please help it out</strong></p>
