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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:35:57+00:00 2026-05-18T08:35:57+00:00

So if I have a variable like var ht = <body><p>Paragraph Here</p></body> If it

  • 0

So if I have a variable like

var ht = "<body><p>Paragraph Here</p></body>"

If it was attached to the DOM I could just do this to get the text

$('p').text(); 

But can I do the same kind of selection just on a variable that has not yet been attached to the dom?

  • 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-18T08:35:58+00:00Added an answer on May 18, 2026 at 8:35 am

    The jQuery object will take HTML and make it in to a DOM structure for further query, you can pass it in directly to create the object, or use it as a context if you just wish to query it.

    Edit: For some reason it seems necessary to wrap it in a DIV, if not already within one in this example. See the jQuery object documentation on this method for further information.

    See test framework for system at: http://jsfiddle.net/hUMqU/

    var ht = "<body><p>Paragraph Here</p></body>";
    $('<div>' + ht + '</div>').find('p').text();
    

    or as context:

    var ht = "<body><p>Paragraph Here</p></body>";
    $('p', '<div>' + ht + '</div>').text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript/jQuery block as a callback after $.get function: function myCallBack(data, textStatus)
I have a page that's working fine in Firefox 3.5.6 but not in IE
Is it possible to create an Iframe using document.createElement(iframe); and then set a variable
I am an iPhone App Developer and have very very little knowledge about css.I
I have a collection of span elements. In the code I have a global
1) In the following code, what is the reasoning behind making gameOfLive a variable
We have a windows application that contains an ActiveX WebBrowser control. As part of
I have a unique issue - I am designing a web application that creates
Quick question, I'm trying to pass a value to a variable and then run
I'm building a custom page caching utility that uses a syntax like {Substitution:GetNonCachedData} to

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.