• Register
1 vote
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'.
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 
document.body.appendChild(z);

The above code will give error. 

Following code will work:

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

Related questions

0 votes
1 answer 5 views
5 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 5 days ago muktaa 34.4k points
0 votes
1 answer 14 views
14 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
0 votes
1 answer 24 views
24 views
Problem: When I upload file in my dropzone, it do not work. Usually it's work very well, but since 1 month I have this JS Error : Uncaught TypeError: Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'. That is the code, when I use FormData : ... 08-2019 : Okay, just tested, and it's works on Microsoft Edge 44.17763.1.0 but not on Google Chrome or Firefox, any explanation?
asked Apr 24 sumaiya simi 43.9k points
0 votes
1 answer 25 views
25 views
Problem : Any help, I am facing following error: Uncaught (in promise) domexception: failed to load because no supported source was found.
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.5K views
2.5K 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 17 views
17 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
1 answer 1.6K views
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.
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 20 views
20 views
Problem: can anybody help me understanding this error : uncaught error: bootstrap's javascript requires jquery at bootstrap.min.js:6.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 3K views
3K 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