Here’s a short function to remove a row from a table using the row’s id
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
function removeRow(id) { var tr = document.getElementById(id); if (tr) { if (tr.nodeName == 'TR') { var tbl = tr; // Look up the hierarchy for TABLE while (tbl != document && tbl.nodeName != 'TABLE') { tbl = tbl.parentNode; } if (tbl && tbl.nodeName == 'TABLE') { while (tr.hasChildNodes()) { tr.removeChild( tr.lastChild ); } tr.parentNode.removeChild( tr ); } } else { alert( 'Specified document element is not a TR. id=' + id ); } } else { alert( 'Specified document element is not found. id=' + id ); } } |
Very Good! Many Thanks!!! Bye
my pleasure dude
How bout pairing this script with one that ads a row instead of deleting?
i will have to look the code for that one.
This is perfect! Thanks for the clear article!
you’re welcome 😉
This is a very exciting post, I was looking for this information. Just so you know I found your site when I was doing research for blogs like mine, so please check out my site sometime and leave me a comment to let me know what you think.
Thanks for this awesome source! 😉
@edward: you’re welcome 😉
Awesome 🙂 Works lik magic!
Was looking for something lik this
dfdf