Copy table row and increment all name attributes
<p>Let's have a table like this:</p>

<pre><code>&lt;table&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="FirstName1" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="LastName1" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="FirstName2" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="LastName2" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I want to have a button that will add new row at the end of the table with incremented name attributes so it will look like this:</p>

<pre><code>&lt;table&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="FirstName1" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="LastName1" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="FirstName2" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="LastName2" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="FirstName3" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="LastName3" /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>And so on.</p>

<p>So far I have this but it does not increment name attributes:</p>

<pre><code>$("#newRowButton").click(function(){
  $("table tr:last").clone().appendTo("table");
});
</code></pre>
