• Register
0 votes
1.6k views

Problem :

Facing following javascript issue
failed to execute 'removechild' on 'node': the node to be removed is not a child of this node.
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I think your myCoolDiv element is not a child of the player container. It is the child of the div that you have created as a  wrapper for it Note : markerDiv in the first part of the code. That is why it is failing so removeChild only removes the children and not the descendant.

So you must remove the wrapper div.

Following is the "not adding it at all" option:

e.g.

var markerDiv = document.createElement("div");

markerDiv.innerHTML = "<div id='MyCoolDiv' style='color: #2b0808'>123</div>";

document.getElementById("playerContainer").appendChild(markerDiv.firstChild);

// -------------------------------------------------------------^^^^^^^^^^^

setTimeout(function(){

    var myCoolDiv = document.getElementById("MyCoolDiv");

    document.getElementById("playerContainer").removeChild(myCoolDiv);

}, 1500);

<div id="playerContainer"></div>

9 7 4
38,600 points

Related questions

0 votes
1 answer 18 views
18 views
Problem: Facing following javascript issue: failed to execute 'removechild' on 'node': the node to be removed is not a child of this node.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
0 answers 13 views
13 views
Problem: failed to execute 'replacechild' on 'node': the node to be replaced is not a child of this node
asked Feb 23 Muneeb Saadii 130k points
0 votes
1 answer 8 views
8 views
Problem: I want to append an existing div to have a particular design along with an error message extracted out of an array. This was my attempt: if (data.errors.firstName) { document.getElementById("firstName").classList.add("has-error"); document.getElementById("firstName-group"). ... researching means that is a string which I can add in as it is not a valid dom node. How can I do this properly?
asked Apr 30 muktaa 34.6k points
0 votes
1 answer 15 views
15 views
Problem: I Need help; Failed to execute 'appendchild' on 'node': parameter 1 is not of type 'node'.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.6K views
1.6K views
Problem : I want to drag and drop the image on the div. The image does not get dragged onto a div and gives the below error : Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.draganddrop.html:20 dropdraganddrop.html:26 ondrop
asked Jan 18, 2020 jwilliam 3.9k points
1 vote
1 answer 1.1K views
1.1K views
Problem : Trying to drag and drop an image on a div. but the image does not get dragged on to the div and gives the following error: uncaught typeerror: failed to execute 'appendchild' on 'node': parameter 1 is not of type 'node'.
asked Nov 11, 2019 peterlaw 6.9k points
1 vote
1 answer 18 views
18 views
Problem : I have found this > Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': tainted canvases may not be exported.
asked Apr 24 Abik Dey 4k points
0 votes
1 answer 490 views
490 views
Problem : I want to save my canvas to a img. I have this function: function save() { document.getElementById("canvasimg").style.border = "2px solid"; var dataURL = canvas.toDataURL(); document.getElementById("canvasimg").src = dataURL; document. ... error: Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. What should I do?
asked Nov 21, 2019 peterlaw 6.9k points
0 votes
1 answer 5 views
5 views
Problem: Is there a solution for this? > Failed to execute 'json' on 'response': body stream is locked.
asked May 7 Junia Phoebe 15.3k points
0 votes
1 answer 4 views
4 views
Problem: Someone somehow assist me please >Failed to execute 'drawimage' on 'canvasrenderingcontext2d'
asked 5 days ago Sawyer Parviz 13.4k points