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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:53:12+00:00 2026-06-04T00:53:12+00:00

I am trying to load an ID from a page with jQuery’s load(). Here

  • 0

I am trying to load an ID from a page with jQuery’s load(). Here is the HTML of the loaded page:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
        <section id="content" class="contentPage">
        <h3>Home</h3>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean id eros orci. Nam id interdum enim. Ut mauris enim, scelerisque a pellentesque in, molestie eget sem. Ut sagittis erat eget elit euismod laoreet. Vivamus odio mauris, aliquam sed ornare non, tempus nec augue. Proin id lectus elit. Donec pharetra viverra lectus, pellentesque sollicitudin magna gravida pellentesque. Quisque tristique, libero at pulvinar rutrum, neque nunc tincidunt lorem, sit amet varius lorem leo sit amet mi. Quisque vehicula diam in libero aliquet dapibus. Nullam eget arcu a sapien scelerisque fermentum. Integer suscipit magna sed quam aliquet mattis. Suspendisse in erat eu nisi hendrerit bibendum. Aliquam blandit malesuada metus. Duis dapibus consequat ultrices.
        </p>
        </section>
        <!-- end Page1 -->
</body>
</html>

From this I only wish to load the #content section (and for compatibility reasons I cannot get rid of everything but that section). I am working with variables to call this function, but this doesn’t seem to work:

var firstLink = $("ul > li:first-child > a");   
$("#sectionContainer").load("./" + firstLink.attr("href") + " #content");

In which the variable firstLink.attr("href") returns a link such as Pages1.html. When the last part ( + " #content") is left out, the script works as it should.

I thought this would work, because jQuery’s documentation states you can do the following:

$('#result').load('ajax/test.html #container');

Any idea what I am doing wrong? Or can’t you add this kind of text to a variable in jQuery?

  • 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-06-04T00:53:14+00:00Added an answer on June 4, 2026 at 12:53 am

    If you are using

    var firstLink = $("ul > li:first-child > a");   
    $("#sectionContainer").load("./" + firstLink.attr("href") + " #content");
    

    Then in the page referred by first link should have an element (for example a div or a section) with ID content

    As in your case your page (first link) contains id Pages1 you can use #Pages1 in place of #content

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

Sidebar

Related Questions

I'm trying to load content from another page div into another page div. What
I'm trying to do a loop where I load some content from another page
I'm trying to load a DIV element from an external page into my current
I am trying to load mysql data from my database from a html select
I need to load an html string into memory from the page and remove
I am trying to load some elements from another page under my site, and
First of all In Jquery loading html frag with dynamic content using load() is
Trying to bring in a specific DIV from a page called by the jQuery
I have a small page: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html>
I'm trying to load a jsp-file into a jQuery UI dialog http://jqueryui.com/demos/dialog/ . The

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.