问题描述
{
$
var innerDiv = document.getElementById(" innerDiv");
$
var newDiv = document.createElement(" div");
for(var i = 0; i< innerDiv.childNodes.length; i ++)
{
var anchor = newDiv.appendChild(document.createElement(" a"));
anchor.setAttribute(" href"," http://www.google.com");
anchor.text = innerDiv.childNodes [i] .textContent;
newDiv.appendChild(document.createElement(" br"));
}
innerDiv.replaceNode(newDiv)
{
var innerDiv = document.getElementById("innerDiv");
var newDiv = document.createElement("div");
for (var i = 0; i < innerDiv.childNodes.length; i++)
{
var anchor = newDiv.appendChild(document.createElement("a"));
anchor.setAttribute("href", "http://www.google.com");
anchor.text = innerDiv.childNodes[i].textContent;
newDiv.appendChild(document.createElement("br"));
}
innerDiv.replaceNode(newDiv)
在Firefox Debugger中,出现此错误:"TypeError:innerDiv.replaceNode不是函数"。这有什么不对?
In Firefox Debugger, getting this error: "TypeError: innerDiv.replaceNode is not a function". What is wrong here?
推荐答案
这篇关于TypeError:innerDiv.replaceNode不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!