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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:09:31+00:00 2026-05-27T04:09:31+00:00

I understand so far that in Jquery, with html() function, we can convert HTML

  • 0

I understand so far that in Jquery, with html() function, we can convert HTML into text, for example,

$("#myDiv").html(result);

converts “result” (which is the html code) into normal text and display it in myDiv.

Now, my question is, is there a way I can simply convert the html and put it into a variable?

for example:

var temp;
temp = html(result);

something like this, of course this does not work, but how can I put the converted into a variable without write it to the screen? Since I’m checking the converted in a loop, thought it’s quite and waste of resource if keep writing it to the screen for every single loop.

Edit:

Sorry for the confusion, for example, if result is " <p>abc</p> " then $(#mydiv).html(result) makes mydiv display "abc", which “converts” html into normal text by removing the <p> tags. So how can I put "abc" into a variable without doing something like var temp=$(#mydiv).text()?

  • 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-27T04:09:31+00:00Added an answer on May 27, 2026 at 4:09 am

    No, the html method doesn’t turn HTML code into text, it turns HTML code into DOM elements. The browser will parse the HTML code and create elements from it.

    You don’t have to put the HTML code into the page to have it parsed into elements, you can do that in an independent element:

    var d = $('<div>').html(result);
    

    Now you have a jQuery object that contains a div element that has the elements from the parsed HTML code as children. Or:

    var d = $(result);
    

    Now you have a jQuery object that contains the elements from the parsed HTML code.

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

Sidebar

Related Questions

As far as I understand, the onchange event of a text input element is
As far as I can understand, when I new up a Linq to SQL
I was just trying to learn and understand jQuery source code (so far with
I have gotten so far that I understand entity objects have an ID while
I can't get Netbeans to auto-complete my selectors for JQuery, example: <a id=hello href=#>Hello</a>
I got this html code from a book that i'm using to learn jquery
I have an input box for which I am using the Jquery autocomplete function.
As far as I understand, if I want to get my database under source
As far as I understand, binding to a var in ActionScript is carried out
As far as I understand, https is http plus SSL/TLS. What do I need

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.