Access element after append
<p>I've read through every post I can find on this topic and have tried many "solutions" but it just doesn't seem to be working for me.</p>

<pre><code>$(function () {

    var options = {
        source: [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            ],
        minLength: 2
    };  

    $('#btn_addline').on ("click", function () {

        // get existing line number and increment by one
        var linenum = parseInt ($('#numlines').val()) + 1;

        // update hidden numlines field with new value
        $('#numlines').val(linenum);

        // define new field names
        var line_field = 'report['+linenum+'][line]';
        var notes_field = 'report['+linenum+'][notes]';
        var contact_field = 'report['+linenum+'][contact]';

        var newLine = $('&lt;tr&gt; \
            &lt;td&gt;&lt;input name="'+line_field+'" id="'+line_field+'" type="text" size="2" maxlength="2" class="form" value="'+linenum+'" readonly="readonly" /&gt;&lt;/td&gt; \
            &lt;td&gt;&lt;input name="'+notes_field+'" id="'+notes_field+'" type="text" size="96" maxlength="256" class="form" /&gt;&lt;/td&gt; \
            &lt;td&gt;&lt;input name="'+contact_field+'" id="'+contact_field+'" onFocus="attach_autocomplete()" type="text" size="32" maxlength="32" class="form" value="test123" /&gt;&lt;/td&gt; \
            &lt;/tr&gt;');

        // append new line to table
        //$('#report_items').append(newLine);

        $('#report_items').append(newLine)
            .hide()
            .fadeIn('Normal', function() {
                $(this).find('#'+contact_field).val('test');
                //alert ($(this).find('#'+contact_field).val());
                alert (contact_field);
                alert ($('#'+contact_field).val());
            });

        //$('#'+contact_field).autocomplete(options);

    });
});
</code></pre>

<p>The new HTML is appended properly, however nothing I do can access those elements.  I've tried various suggestions throughout the site and am get frustrated now and am hoping for some help.</p>

<p>The third alert - <code>alert ($('#'+contact_field).val());</code> - returns "undefined".</p>

<p>To be clear, I have thoroughly gone through the list of similar questions, but have not found a solution.  It is very possible I am missing something obvious, or I don't quite understand the relation between appending elements and it's effect on the DOM, but in any case I could really use a hand here.</p>

<p>Cheers.</p>
