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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:17:10+00:00 2026-05-22T22:17:10+00:00

In JavaScript if I append a child which has an ID to another place

  • 0

In JavaScript if I append a child which has an ID to another place then it’s removed from original location where they currently are.

In javascript I have an event where I can get selector by using this inside the function

$('.').event(function(){
    this
});

This is passed to another function and they work fine. Now I want to pass the clone instead of the object; and remember that this does not have ID.

The old code works by passing this to function as DoSomething(this)

if I make a clone using jQuery clone then I have the jQuery object. So how do I get a reference to this instead of the jQuery object when working with the clone?

var clone = $(this).clone() // this is jQuery object. 
//how do I get this out of clone? 
  • 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-22T22:17:10+00:00Added an answer on May 22, 2026 at 10:17 pm

    if I append a child which has an ID to another place then it’s removed from original location where they currently are.

    Yes, but the same is true of a child node that doesn’t have an id attribute as well. An id is only an easy way for you to get a reference to the Element node object; it makes no difference to DOM insertion of cloning behaviour.

    In javascript I have an event where I can get selector by using this inside the function

    No, this in an event handler gives you the DOM Element node object, not a selector string. A Node can be turned into a jQuery wrapper around it using $(node) and a selector can be turned into a jQuery wrapper on the list of matching nodes using $(selector) but other than this overloading in the jQuery API they’re completely different animals.

    To pull a Node back out of a jQuery wrapper you can use the get() method or simple array-like access:

    var clonedNode= $(this).clone()[0];
    
    var clonedNode= $(this).clone().get(0);
    

    to taste. (get() has some extra features which you don’t need here.)

    To get the selector used to create a jQuery wrapper you can use the selector property, but this won’t return anything if the wrapper was created from a node object ($(this)) rather than a selector.

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

Sidebar

Related Questions

I have the following javascript code, which is modified from the SimpleUpload demo in
I have a table row which contains a textbox and it has an onclick
I have a UserControl that has some javascript I'd like to inject into a
I have a javascript function which get datagrid's header into THEAD tags. This code
I have a javascript function I wrote to append a select box to a
I have a global javascript function which .appends() a tooltip element to any element
I have a page which uses javascript to add some textboxes to the page,
I have the following javascript: css = document.createElement('style'); css.setAttribute('type', 'text/css'); css_data = document.createTextNode(''); css.appendChild(css_data);
I have a problem, which is not easily described. I'm writing a web application
I have a bookmarklet which inserts a CSS stylesheet into the target DOM via

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.