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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:53:03+00:00 2026-05-28T17:53:03+00:00

Strange behavior I noticed. I have a hidden (display:’none’) HTML on a page. Then

  • 0

Strange behavior I noticed. I have a hidden (display:’none’) HTML on a page. Then I create a tooltip and extract some data from that hidden HTML into this tooltip, as an example, this way:

 $('#tooltip').html( $('#hiddenElement').html() );

If I modify class name within that hidden html (which is now inside of tooltip) that class name always remains original (unchanged) when it is accessed through DOM:

 alert($('#hiddenElement .element').hasClass('some-class');

So it looks like extracting HTML does not work well as if you use a copy of it which does not reflect DOM. Can anyone explain what really happens? I do not have a test case. Hopefully someone is familiar with what I describe. Thanks

  • 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-28T17:53:03+00:00Added an answer on May 28, 2026 at 5:53 pm

    $('#hiddenElement').html() returns the innerHtml of #hiddenElement as one single string.

    Inserting that string into $('#tooltip').html( /*here*/ ); will cause jQuery to detect that you’ve given a string, and therefore it will continue and parse the string to new HtmlElement‘s. This means you’ve effectively created a clone from the contents of #hiddenElement, in a way that costs a lot more time than jQuery.fn.clone().

    If you do not want to create clones, you could instead use jQuery.fn.contents():

    $('#tooltip').html( $('#hiddenElement').contents() );
    

    However, as this does not clone the contents, it will move them to a new location, and therefore the content will no longer be in the #hiddenElement.

    As far as I know, there is no way for a single DOM-node to be in two parent nodes at the same time.

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

Sidebar

Related Questions

I've experienced rather strange behavior of JSTL forEach tag. I have some bean called
I am trying out the (latest) Android SDK, and noticed some strange behavior. I've
i have just noticed something strange in some asp.net markup. I have a standard
I just noticed a strange behavior with overload resolution. Assume that I have the
So I noticed some strange behavior when using a subclass of a NSManagedObject as
I have noticed a rather strange behaviour in IE. I have a HTML form
I am getting some strange behavior involving database queries that I have never seen
I am using FileWriter and I have noticed strange behavior. I buffer my collection
I have just noticed a strange behavior of ComboBox component. I am using it
I noticed a strange behavior in Knockout's template rendering. I have a simple Knockout

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.