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 5940981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:02:43+00:00 2026-05-22T16:02:43+00:00

I recently wrote a script in which I needed an element to move to

  • 0

I recently wrote a script in which I needed an element to move to the top when it was clicked on. I used, and have been using for years, the following code in the onclick function:

this.parentNode.appendChild(this.parentNode.removeChild(this));

The script wasn’t working, and so I messed around with the code, trying things I’d never done before in an effort to fix it. I thought the problem might lie in this line of code. Actually, it turned out to have nothing to do with it, but while I was tinkering around, I noticed that the following code seems to perform the same function.

this.parentNode.appendChild(this);

As far as I can tell, there is no difference. The former feels “better” to me, but I can’t really say why. Is there an actual difference? If not, I’ll start using the latter and save eighteen characters 🙂

  • 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-05-22T16:02:44+00:00Added an answer on May 22, 2026 at 4:02 pm

    this is not a child of this.
    You need to remove the child from the parent node.

    However, appendChild will implicitly remove the node from any existing parent (elements cannot have multiple parents):

    If the node already exists it is removed from current parent node, then added to new parent node.

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

Sidebar

Related Questions

I have a Python script I recently wrote that I call using the command
I recently wrote a script which queries PyPI and downloads a package; however, the
Alright, I recently wrote a ajax push script which had php on the backend
I have recently been put in charge of debugging two different programs which will
I recently wrote a script which parsed a text representation of a single binary
I recently wrote a parser in Python using Ply (it's a python reimplementation of
I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I recently wrote a class for an assignment in which I had to store
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
I recently wrote a program that used a simple producer/consumer pattern. It initially had

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.