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

  • SEARCH
  • Home
  • 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 7040509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:55:37+00:00 2026-05-28T01:55:37+00:00

I need some javascript (not JQuery etc) codes to copy a clone node and

  • 0

I need some javascript (not JQuery etc) codes to copy a clone node and insert it just next
to the copied node. For eg.

<a>
    <b>
        <ab></ab>
        <bc></bc>
    </b>
</a>

Now after copying the <b> node from the source xml and appending it as next sibling,

    <a>
        <b>
            <ab></ab>
            <bc></bc>
        </b>
        <!-- this is the copied node that will be appended. -->
        <b>
            <ab></ab>
            <bc></bc>
        </b>
        <!-- copied node ends here. -->
    </a>

I shall be grateful If some body show me some code example, which is supported in atleast Mozilla2 and IE5+.
The CloneNode method doesnot works properly in many primitive version of major browsers. CloneNode is however supported in All IE browsers. So cloneNode method will not be a solution.

  • 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-28T01:55:37+00:00Added an answer on May 28, 2026 at 1:55 am

    Assuming that you are getting the required node by ID, here’s how you can clone an existing node and append the clone as a sibling node:

    var node = document.getElementById("toBeCloned");
    var parentNode = node.parentNode;
    alert(parentNode.outerHTML);
    var clonedNode = node.cloneNode(true);
    clonedNode.removeAttribute("id");
    parentNode.appendChild(clonedNode);
    alert(parentNode.outerHTML);
    

    The alerts will show what the XML looked before and after the insertion.

    This code will work with Mozilla and any reasonable version of IE. I cannot guarantee IE5 to IE7 support because I don’t have access to those browsers.

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

Sidebar

Related Questions

I have some javascript/jquery code and need to some php into it be the
I need some assistance with some javascript/jquery I have put in place. The function
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I need to output some JavaScript in a WebControl based on some processing and
I need to attach some javascript to the onchange event of the Zend_Form_Element. How
I need to write some javascript to strip the hostname:port part from a url,
Lets say you need to attach some JavaScript functionality to an ASP.NET User Control
Hallo, i need to write some javascript that gets the contents of a userfield
How to change HTML background with JavaScript Function? I need some simple function to
I'm working on some ECMAScript/JavaScript for an SVG file and need to get the

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.