Possible Duplicate:
What is the best way to remove a table row with jQuery?
If I have table with 3 rows using tr
tag, how do I remove the first row (index 0) with either jquery or some other javascript?
Possible Duplicate:
What is the best way to remove a table row with jQuery?
If I have table with 3 rows using tr
tag, how do I remove the first row (index 0) with either jquery or some other javascript?
This would remove the 3rd row in a table.
$("table tr:eq(2)").remove();
Also, don't forget to use <thead>
and <tbody>
in your <table>
. It makes things more accessible and helps if you want to use a plug-in for sorting later down the road.
Here's the "some other javascript" approach, which is itself very simple:
document.getElementById("myTable").deleteRow(0);