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

  • Home
  • SEARCH
  • 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 6091273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:18:31+00:00 2026-05-23T12:18:31+00:00

I have: <p>Paragraph One</p> <p>Paragraph Two</p> <script src=http://www.google.com/jsapi></script> <script> google.load(jquery, 1); </script> <script> var

  • 0

I have:

<p>Paragraph One</p>
<p>Paragraph Two</p>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
</script>
<script>
var x = $('p');
x.each(function(index) {
    $('body').append($(this).html().replace('<','&lt;') + '<br>');
});
</script>

I expected to see:

&lt;p>Paragraph One&lt;/p><br>
&lt;p>Paragraph Two&lt;/p><br>

But instead, the p tag itself is missing.

I’m trying to make my output look like console.log, which would identity x as two (2) paragraph elements.

It’s getting the html within the paragraph, but console.log shows it AS a paragraph. So I guess I need to go up a level and then back down again?

  • 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-23T12:18:32+00:00Added an answer on May 23, 2026 at 12:18 pm

    This is because $(this).html() will only give you the content of the <p> element, not element itself.

    Do this:

    var x = $('p');
    x.each(function(index) {
        var p_html = this.outerHTML || $('<div>').append($(this).clone()).html();
        $('body').append(p_html.replace('<','&lt;') + '<br>');
    });
    

    This takes each <p> element, and gets its .outerHTML property (which is like innerHTML but includes the owner’s tag as well).

    If the .outerHTML property isn’t supported (I’m looking at you Firefox!) then it uses the clone()[docs] method to make a clone of the <p>, adds it to a new <div> and gets the .html() of the <div>.

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

Sidebar

Related Questions

http://www.keironlowe.host56.com/Website%20Testing/index.html At the bottom below the paragraph of text I have two images with
I have a style for paragraph as <div id=content> Text <ul> <li>One</li> <li>Two</li> </ul>
I have two models as follows: class Tag(models.Model): # ... class Paragraph(models.Model): tags =
I have two paragraphs of text, one is saved in a file while the
I have to merge two xml documents using xslt 1.0. Each xml document has
I have a paragraph of text in a javascript variable called 'input_content' and that
I have a paragraph of text below that I want to use an input
I have a paragraph of text and i want to replace some words using
I have a big paragraph of text that is divided into subparagraphs with <br>
I have text within a paragraph tag that that fits snug on the bottom

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.