MrMastermind Posted September 25, 2007 Share Posted September 25, 2007 Hi, I'm trying to write a function that gets the innerHTML from hidden DIV's to generate a javascript file. After the innerHTML is written to another DIV, I want to delete the div. But somehow I can't get it right. The best I could do was "d.parentNode.removeChild(child);" but that doesn't work. I've tried other approaches, but no luck. Any help would be appreciated: function createJS(){ var d = document.getElementById('eFormOutput'); var children = d.childNodes; var code = ""; for(i=0;i<children.length;i++){ var child = children[i].childNodes[0]; if(child.id.substring(0,2) == "js"){ code += "\n" + child.innerHTML; d.parentNode.removeChild(child); } } document.getElementById("jsOutput").innerHTML += code; } Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/70640-solved-cannot-delete-child-using-removechild/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.