问题描述
在Internet Explorer利用此行的document.getElementById(左)。的getElementsByTagName(TBODY)[0] .innerHTML =的document.getElementById(左)。的getElementsByTagName(TBODY) [0] .innerHTML +字符串;
是给我一个 SCRIPT600:无效的目标元素进行此操作。 ...字符10
In Internet Explorer this line document.getElementById("left").getElementsByTagName("tbody")[0].innerHTML = document.getElementById("left").getElementsByTagName("tbody")[0].innerHTML + string;
is giving me a SCRIPT600: Invalid target element for this operation. …character 10
的字符串很简单,它包含了一组tablerows的。这在Chrome,Safari或Firefox正常工作。是否有这样做的更好的办法?什么我做的是,一旦用户到达我追加tablerows到表中装载更多的内容页面的底部。这是一个类型的交易AJAX的无限滚动式 - 客户端请求。我使用Javascript和将preFER留在Javascript的在这一点上并没有改变jQuery的只是为这个任务。
The string is simply that which contains a set of tablerows. This works fine in Chrome, Safari or Firefox. Is there a better way of doing this? What I am doing is once the user gets to the bottom of the page I am appending tablerows into the table to load more content. It's a sort of AJAX infinite scrolling type of deal - client requested. I am using Javascript and would prefer to stay with Javascript at this point and not change to jQuery just for this task.
更新也同:的document.getElementById(左)的innerHTML =的document.getElementById(左)的innerHTML +字符串;
此外,左边是<表ID =左>
Update also the same with: document.getElementById("left").innerHTML = document.getElementById("left").innerHTML + string;
Also, left is <table id="left">
推荐答案
是的,你需要首先将它们包装是这样的:
Yes you will need to wrap them first like this:
var div = document.createElement("div");
div.innerHTML = "<table><tbody>" + string + "</tbody></table>";
document.getElementById("left")
.appendChild(div.firstChild.tBodies[0]);
这篇关于IE浏览器:无效的目标元素 - 使用的innerHTML +字符串追加表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!