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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:24:21+00:00 2026-05-13T18:24:21+00:00

Sorry, if the title is too obscure ;D. Actually the problem is, lets say

  • 0

Sorry, if the title is too obscure ;D.

Actually the problem is, lets say i am this code.

<span id="spanIDxx" style="blah-blah">
   <tag1>code here </tag2> sample text 
   <tag2>code here </tag2> html aass hhddll
   sample text
</span>

Now if i will use the code.

jQuery("#spanIDxx").html();

then it will return just the innerHTML excluding <span id="spanIDxx" style="blah-blah">
but i want something which can return the innerHTML including the specified element.

  • 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-13T18:24:22+00:00Added an answer on May 13, 2026 at 6:24 pm

    This will create a new div and append a clone of your element to that div. The new div never gets inserted into the DOM, so it doesn’t affect your page.

    var theResult = $('<div />').append($("#spanIDxx").clone()).html();
    
    alert( theResult );
    

    If you need to use this frequently, and don’t want to bother with adding yet another plugin, just make it into a function:

    function htmlInclusive(elem) { return $('<div />').append($(elem).clone()).html(); }
    
    alert( htmlInclusive("#spanIDxx") );
    

    Or extend jQuery yourself:

    $.fn.htmlInclusive = function() { return $('<div />').append($(this).clone()).html(); }
    
    alert( $("#spanIDxx").htmlInclusive() );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the slightly rubbish title. I could not think how to describe this
I'm sorry I could not think of a better title. The problem is the
Okay, the title is not saying too much, sorry. Essentially it's an Architecture Question
first of all, sorry for the non descriptive title, I'm just too rushed so
Well, sorry about the confusing title but I'm having a slightly annoying problem with
I'm sorry for ambiguous title, but this question is hard for me to put
Sorry for the vague title, I didn't know how else to phrase this. Suppose
Sorry if title is not too clear but I think it's about right. NEhow,
Sorry for unclear title - I don't know how to describe that problem in
I am new to Ruby and Rails so sorry if this looks too noob.

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.