I know this is an easy concept, but I just can’t seem to get it working. Any ideas why? Here is my code:
var oldChild = document.getElementById("sbX1");
var newChild = document.createElement("div");
newChild.id= "sbYY1";
oldChild.replaceChild(newChild, oldChild);
You’re calling
replaceChild()onoldchild, when you ought to be calling it on the parent node ofoldchild