Focus into a newly replaced text field using jQuery
<p>I am using jQuery to replace the HTML of a text field when it gets focus. My code looks like this:  </p>

<pre><code>&lt;div id="my_field"&gt;
    &lt;%= f.text_field :first_name, :value =&gt; "Enter Name" %&gt;
&lt;/div&gt;
</code></pre>

<p>My jQuery used to replace the HTML inside my_field:</p>

<pre><code>$("#my_field")
    .delegate('#my_field input', 'focus', function(e){
        if($(this).attr('type') == 'text'){
            $(this).parent().html('&lt;input type="text" value="" name="..." id="name"&gt;');
        }
    });
</code></pre>

<p>Just after replacing the HTML, the newly created text box does not get the focus. What should I do to get the cursor on the text box?</p>
