• Register
1 vote

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'.
6 5 3
6,930 points

1 Answer

0 votes

Solution :

Your function must be returning a string rather than the div node. And appendChild can only append a node.

e.g., if you try to appendChild to the string:

var z = '<p>test satu dua tiga</p>'; // is a string 

The above code will give error. 

Following code will work:

var z = document.createElement('p'); // is a node
z.innerHTML = 'test satu dua tiga';
9 7 4
38,600 points

Related questions

0 votes
1 answer 873 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 jwilliam 3.9k points
0 votes
1 answer 768 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 Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 1.2K views
Problem : I am facing following error message: DOMException: Failed to load because no supported source was found in video.play(); line. I have started getting this issue only after adding following code: video.setAttribute('crossorigin', 'anonymous'); I am trying to develop an app in the mobile so ... 0); setTimeout(loop, 1000 / 30); // drawing at 30fps } })(); }, 0); </script> </body> </html>
asked Nov 27, 2019 alecxe 7.5k points
0 votes
1 answer 197 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 1.9K views
Problem : I am trying to execute bootstrap jquery code but getting below error uncaught error: bootstrap's javascript requires jquery at bootstrap.min.js:6
asked Oct 22, 2019 peterlaw 6.9k points