I'm trying to create a new column when I press the "+" button.
The problem that I have is:
I click the button and it generate a column after the last one. How Can I do it for generate it before?
I put my table here:
<table>
<tr>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td class="total">0</td>
</tr>
<tr>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td class="total">0</td>
</tr>
<tr>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td><input value = "0"/></td>
<td class="total">0</td>
</tr>
</table>
Thats the code that I have for the moment:
http://jsfiddle.net/2G7Lh/
Thank you very much!
Try
$("tr").find("td:last").before('<td><input type="text" value=""></td>');
Fiddle Demo
.find() the :last td in each tr than insert the element .before() it.
=
change <input type"text" to <input type="text" as commented by Biduleohm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With