Jquery: Clone Row and Append Index to Text Area Name/ID
<p>I have the following table:</p>

<pre><code> &lt;table width="1000" border="1" cellpadding="2" cellspacing="2" bordercolor="#CCCCCC" class="WebApps" id="addIssue"&gt;    
        &lt;tbody&gt;
            &lt;tr&gt;
                &lt;td bordercolor="#f0f0e4" bgcolor="#f0f0e4"&gt;&lt;h3&gt;Open Issues
                &lt;input type="button" class="button" value="+" id="addNewIssue" name="addNewIssue"/&gt;
               &lt;input type="text" id="txtIndex" name="txtIndex" value="&lt;%=vIndex%&gt;"&gt;
                &lt;/h3&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td bordercolor="#FFFFFF" bgcolor="#FFFFFF"&gt;&lt;p&gt;&lt;textarea id="txtOpenIssues0" name="txtOpenIssues0" cols="100" rows="2"&gt;&lt;/textarea&gt;
                &lt;/p&gt;&lt;/td&gt;
            &lt;/tr&gt;    
        &lt;/tbody&gt;                  
        &lt;/table&gt; 
</code></pre>

<p>And the following JQuery script:</p>

<pre><code>$("#addNewIssue").click
        (
            function() 
            {       

                var iX = document.getElementById("txtIndex").value;
                iX ++;
                document.getElementById("txtIndex").value = iX;     

                $('#addIssue tbody&gt;tr:last').clone(true).insertAfter('#addIssue tbody&gt;tr:last'); 

                //Clear out newly added text field.  
                $('#addIssue tbody&gt;tr:last #txtOpenIssues0').val('');     
                return false;       

            }       
        );  
</code></pre>

<p>It works just fine; however, as you can see from my HTML, I am trying to attach an index to the name/id of the text area.  So, upon adding a new row using the Jquery script, i would like to change the name and id of the newly added row to match my index.  So, row one is txtOpenIssues0, and then the newly added row would contain text field txtOpenIssues1, then add another and it'd be txtOpenIssues2, etc.  I have done this successfully without JQuery, but am wanting to try more JQuery solutions.  Currently have jquery 1.6.1  Any help is appreciated.  Thanks!</p>
