Rya*_*yan 0 javascript dom appendchild
我向mozilla目录提交了一个Firefox插件,因此被拒绝了:
item.innerHTML = '<table style="border-collapse: collapse; width: 100%;">'
+ '<tr><td style="line-height: inherit; padding: 0pt; width: 100%;">'
+ word.title
+ '</td></tr>'
+ '</table>';
Run Code Online (Sandbox Code Playgroud)
我跟编辑谈过,他告诉我" use a text node and then insert it using appendChild, textContent, etc"
这对我来说听起来像是完全胡言乱语,我从未使用过TextContent, appendChild等等,而且有点失落.你能告诉我如何做到这一点,我会在我的脚本中编辑其他13个像上面这样的实例吗?
谢谢!
您可能需要按照以下方式执行某些操作:
var t = document.createElement("table"),
tb = document.createElement("tbody"),
tr = document.createElement("tr"),
td = document.createElement("td");
t.style.width = "100%";
// note the reverse order of adding child
tr.appendChild(td);
tb.appendChild(tr);
t.appendChild(tb);
// more code to populate table rows and cells
item.appendChild(t);
Run Code Online (Sandbox Code Playgroud)
注意:以这种方式创建表有一些注意事项,因为浏览器之间的工作方式不同.我建议咨询MDN以确定FF.
| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |