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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:02:19+00:00 2026-05-27T20:02:19+00:00

Here is the thing, I have a textarea (with ID input_container) full of HTML

  • 0

Here is the thing,

I have a textarea (with ID “input_container”) full of HTML code, the simple example is:

<!doctype html>
<html>
    <head></head>
    <body>
        <a href="www.example.com">the other place</a>
    </body>
</html>

I parsed it using jQuery, here is my code:

I have all this HTML string into variable named domString like this:

domString = $('#input_container').val();

To get a parse HTML of everything inside variable domString, I had to wrap it with another tag, so I did:

dom = "<allhtml>" + domString + "</allhtml>";

And got everything inside a jQuery selector to be parsed:

dDom = $(dom);

After that I checked what’s in dDom, so I did

alert(dDom.html());

That should give me anything inside the tags, right?

But unfortunately, all I get is:

<a href="www.example.com">the other place</a>

And all the other tags are mysteriously gone. Can anyone explain this phenomenon and tell me how to really parse all the DOM?

Thank you

  • 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-27T20:02:20+00:00Added an answer on May 27, 2026 at 8:02 pm

    From the jQuery documentation:

    When passing in complex HTML, some browsers may not generate a DOM
    that exactly replicates the HTML source provided. As mentioned, we use
    the browser’s .innerHTML property to parse the passed HTML and insert
    it into the current document. During this process, some browsers
    filter out certain elements such as <html>, <title>, or <head>
    elements. As a result, the elements inserted may not be representative
    of the original string passed.

    This should work instead:

    $('<html />').append($('<head />')).append($('<body />').append($('<a href="www.example.com">the other place</a>')));
    

    This is kind of a weird thing to do, though- you might want to think about other ways to do what you’re trying to accomplish, I worry that you might be suffering from the XY Problem.

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

Sidebar

Related Questions

yesHave a simple thing here, but not that handy in PHP. Basically I have
Here's the thing: I have two applications, written in C++ and running on two
Here is the thing. I currently have a tabBar controller, with several navigation controllers
Here's the thing. I have an interface, and I would to put the Include
Here is the thing. Right now I have this e-commerce web site where people
I have some doubt on wget command. Here is the thing I want to
I have a problem with docking. Here is the thing. I hope I can
I have installed ibrowser plugin. Do every thing in here and here Addin javascript
here is my working php explode code for NON links: <?php $textarea = get_custom_field('my_custom_output');
I have an HTML document, with the jquery code $(function(){ [...] $(#newNotice).click(function(){ $(#properties).load(testDiagramm.html #NoticeForm);

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.