I have a little problem. I have some dynamically created tables and each row has an id. I want to delete the row with the id "x".
I tried the usual method (removeChild) but it doesn't work for tables apparently.
function deleteRow(tableid, rowid)
{
document.getElementById(tableid).removeChild(document.getElementById(rowid));
}
The error I get is: Node was not found" code: "8
I also tried this:
function deleteRow(tbodyid, rowid)
{
document.getElementById(tbodyid).removeChild(document.getElementById(rowid));
}
and got the same error.
I can't use the deleteRow()
method because that one needs the index of the row and I prefer not to search for the id mark the index then delete (even though if I don't find other solutions...).
Something quick and dirty:
if you place
anywhere within the row you want to delete, than its even working without any ids
The parent of the row is not the object you think, this is what I understand from the error.
Try detecting the parent of the row first, then you can be sure what to write into
getElementById
part of the parent.How about:
And, if that fails, this should really work:
to Vilx-:
and what if
row.parentNode
isTBODY
?You should check it out first, and after that do
while
by.tBodies
, probablyAnd what about trying not to delete but hide that row?
From this post, try this javascript:
I tried this javascript in a test page and it worked for me in Firefox.