Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8471821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:54:04+00:00 2026-06-10T16:54:04+00:00

I am trying to drag and drop an image from parent A, which has

  • 0

I am trying to drag and drop an image from parent A, which has several children, to parent B, which is initially empty. I can specify element.parent = document.getElementById(‘foo’), but the document doesn’t naturally flow as if I had placed the element under foo originally.

I’m presently working around this behavior by having JavaScript style the parent to act as if it contained the child and the child to act as if it were contained in the parent, but I would like to know if there’s a better way to have the document updated to look as if the child were placed under the target parent instead of the origin parent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:54:06+00:00Added an answer on June 10, 2026 at 4:54 pm

    You are not moving an item in the DOM correctly – when you do move it correctly the display will update automtically.

    You can’t just set the .parent property. First off, .parent isn’t even a property on the DOM element (it’s .parentNode). Second, it isn’t a property you can directly set (per the DOM spec, it is a read-only property). Instead, you need to do it like this:

    document.getElementById('foo').appendChild(element);
    

    This will remove it from the DOM location it’s currently in and append it as the last child of a new parent node. If you want to place it as a specific child relative to the existing children (e.g. as the 3rd child node or the 1st child node), you can use .insertBefore() instead of .appendChild().

    If wanted to copy the node to a new location rather than move an existing node, you would first have to make a copy of the node (either making it from scratch or using .cloneNode() and then insert the copy into the DOM in the same manner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to drag and drop an image from one spot on the canvas
I'm trying to implement HTML5 Drag and Drop with a custom drag image, which
I am trying out some Drag Drop functionalities and can't discern the difference between
I am trying to handle a drag & drop interaction, which involves mouse down,
Based on this drag/drop article: http://delphi.about.com/od/adptips2005/qt/dropontimage.htm I'm trying to catch an image dragged from
This is my code, i'm trying to drag and drop a card which will
i am trying to implement a standard drag and drop image in wpf using
I've been a long journey trying to drag and drop UIImageViews from a UITableView
i am trying to drag and drop an image of a card on the
I'm trying to build a drag-drop system where images can be dragged into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.