开发者

Selecting a table row in javascript causes IE8 to fail

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

This causes IE to raise "Unknow开发者_Go百科n 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.


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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜