JavaScript - Removechild Ie
I keep on getting a error message from internet explorer whenever I try to remove a node from the document. This code obviously works on every other browser but internet explorer. What am I doing wrong here?
Code: var elem = document.getElementsByTagName("div")[2]; elem.removeChild(document.getElementById("loginContent")); elem.removeChild(document.getElementById("loginContainerLayer")); Thanks for the help. Similar TutorialsHey all. I am trying to remove a child node from an XML document and running into issues. I keep getting errors about not being able to find the child node, even though it very clearly exists. This is my XML http://www.digitalswordsmen.com/at/map11.xml I have tried the code //XML is a reference to my XML, go figure. var ID = 0; var y=XML.getElementsByTagName("id")[ID]; //This line works... alert(y.childNodes[0].nodeValue); //This fails XML.documentElement.removeChild(y); This is the exact error: Error: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://www.digitalswordsmen.com/at/mapFunctions.js Line: 373"] but to no avail. I think the issue is that most examples I've tried to follow only have the root element, then the nodes, but I have a root element, then another level (mapSettings & mapObjects). I don't know how to tell the remove child command that it needs to look in the mapObjects section. I'm totally stuck. Any help is appreciated. Thanks. |