Does anyone know a good way to dynamically add a row to a table in jQuery?
Asked
Active
Viewed 266 times
1
-
1Possible duplicate: http://stackoverflow.com/questions/171027/add-table-row-in-jquery – Luwe Sep 02 '11 at 08:50
2 Answers
0
Try
$('table').append('<tr><td>Foo</td></tr>');

Franquis
- 743
- 1
- 5
- 17
-
use table_id instead of table. If a page contains more then one table then it will create problem. – munjal Sep 02 '11 at 08:54
0
Technically for a cross browser implementation you should do $('table tbody').append("Foo")
Since IE doesn't automatically add the tbody for you but other browsers do.

HaloZero
- 475
- 4
- 15
-
-
There's USUALLY only one tbody per table. But if you have multiple yes, this won't work. I believe the link Luwe goes into more possibilities and cases. – HaloZero Sep 02 '11 at 18:49