Appending to div and being unable to bind the added buttons
<p>I have a php function that echos code of a form that has a button. when that button is click it will append a file field and a another button that if clicked would repeat the above. however when the added button is clicked nothing happened.</p>

<p>I am thinking it has something to do with binding the button.</p>

<p>Here is the code:</p>

<pre><code>$formtoreturn = '
&lt;div class="form_holder"&gt;
    &lt;form action="'.site_url().'xxxxx" method="post" enctype="multipart/form-data" &gt;


    &lt;div id="fields_holder"&gt;
        &lt;span class="form_holder-label" id="fileC"&gt;Select image or images&lt;/span&gt; 
        &lt;div class="fields" id="field1"&gt;
            &lt;input type="file" name="fileID-input[]" id="fileID-input" class="fileC-input"&gt;
            &lt;a rel="add" id="add_file1" class="add_file" href="javascript:;"&gt;&lt;img src="wp-content/plugins/wl_extendor_wishlist/images/add-icon.png"&gt;&lt;/a&gt;
        &lt;/div&gt;

    &lt;/div&gt;
    &lt;div class="clear"&gt;&lt;/div&gt;

    &lt;input type="hidden" value="'.$u_id.'" name="user_id" id="user_id"&gt;
    &lt;input type="submit" name="submittestimonial" value="Submit Testimonial"&gt;
    &lt;/form&gt;
    &lt;iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;script&gt;
var filecount = 1;
var $j = jQuery.noConflict();
$j(document).ready(function() {
    $j(\'#fields_holder\').on(\'click\', \'.add_file\', function() {
        var toappend = \'&lt;div class="fields" id="field1"&gt;&lt;input type="file" name="fileID-input[]" id="fileID-input" class="fileC-input"&gt;&lt;a rel="add" id="add_file1" class="add_file" href="javascript:;"&gt;&lt;img src="wp-content/plugins/wl_extendor_wishlist/images/add-icon.png"&gt;&lt;/a&gt;&lt;/div&gt;\';

        if($j(this).attr("rel") == "add"){
            $j(this).attr("rel", "ded");
            $j("#fields_holder").append(toappend);
            filecount++;
        }
    });
});

&lt;/script&gt;
';
echo $formtoreturn;
</code></pre>

<p>Hope the code and my question is clear.</p>

<p>Thanks in advanced.</p>
