• 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

Please log in or register to answer this question.

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 1.3K 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
0 votes
1 answer 1.2K 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 2.1K 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
0 answers 5 views
Problem: failed to execute 'replacechild' on 'node': the node to be replaced is not a child of this node
asked 6 days ago Muneeb Saadii 2.4k points
0 votes
1 answer 2.6K 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
0 votes
1 answer 342 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
1 vote
1 answer 86 views
How do I modify the URL without reloading the page?
asked Sep 28, 2020 Xaimax 9.5k points
0 votes
1 answer 62 views
I'm trying to render html files, but I'm having an issue. This works. app.get('/randomlink', function(req, res) { res.sendFile( __dirname + "/views/" + "test2.html" ); }); But I don't want to copy and paste dirname thingy over and over, so I tried this ... // test2.html exists in the views folder }); Here's the error. path must be absolute or specify root to res.sendFile Please help me solve this.
asked Jan 23 khaled 280 points
0 votes
2 answers 30 views
Problem I am a bit confused what is a right way to link/include JavaScript file in HTML ? And hoe to do it right ?
asked Oct 17, 2020 alexh 2.5k points
0 votes
1 answer 4 views
Problem: uncaught typeerror: $(...).datetimepicker is not a function
asked Feb 18 Ethan ross 1.8k points