![]() ![]() |
Hi Everyone, I know that there is a few post already on row removal but have read and tried what they are saying but having no luck. But it may be because I am new. Anyway what I am trying to do is remove the third row of a table.
< body id="slam">
< table id="jam">
<tbody>
<tr> 1 </tr>
<tr> 2 </tr>
<tr> 3 </tr>
</tbody>
< /table>
what I have tried is document.getElementsById('slam').getElementsById('jam').getElementsByTagName(tbody).removeChild(rowset[3]); and document.evaluate('//table/tbody/tr[3]',document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null).style.display = 'none'; Any help would be greatly appreciated. |
![]() ![]() |
It's
var theParent = document.getElementById('jam').getElementsByTagName('tbody')[0];
theParent.removeChild(theParent.getElementsByTagName('tr')[2]);
|
![]() ![]() |
For what it's worth, a table also has a rows collection. If there are no rows in a rowToDelete = document.getElementById("jam").rows[2];
rowToDelete.parentNode.removeChild(rowToDelete);
|
![]() ![]() |
Thanks devnull69 for pointing out the 's' also got it working by document.getElementById("jam").deleteRow(2);
Thanks to Monkey2000 point out can just use the table's id Thanks both for the help |

