joedborg
joedborg

Reputation: 18353

Selecting a table row in javascript causes IE8 to fail

document.getElementById("row").innerHTML = "";

This causes IE to raise "Unknown runtime error".

I know this is a known bug, but is there any workaround (except the obvious using a div instead).

Works fine in all other browsers.

Upvotes: 0

Views: 183

Answers (2)

Shadow Wizard
Shadow Wizard

Reputation: 66388

Instead of "nuking" the row like that, just hide it:

document.getElementById("row").style.display = "none";

Same final result (row will disappear from view) without messing too much with the DOM.

Edit: another way to "clear" the element is:

var row = document.getElementById("row");
while (row.childNodes.length > 0)
    row.removeChildNode(row.childNodes[0]);

Should be as cross browser as possible - live example.

Upvotes: 1

user982911
user982911

Reputation: 151

can you provide the HTML code you use? Is there a reason you can't use jQuery?

maybe you could use:

 document.getElementById('table1').deleteRow(_row.rowIndex);

Upvotes: 0

Related Questions