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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:42:54+00:00 2026-05-22T22:42:54+00:00

Lets say i have this: $(‘a’).each(function() { $(this).click(function(e) { e.preventDefault(); var href = $(this).attr(‘href’);

  • 0

Lets say i have this:

$('a').each(function() {
    $(this).click(function(e) {
        e.preventDefault();
        var href = $(this).attr('href');
        $('#somediv').load(href + ' #foo');
    });
});

Now how would I make it load the inner contents of #foo and not the actual div #foo

Still not quite sure what I mean?

<div id="foo">
    <!-- Load these divs only -->
    <div class="children">bar</div>
    <div class="children">bar</div>
    <div class="children">bar</div>
    <div class="children">bar</div>
    <div class="children">bar</div>
    <!-- // -->
</div>

I want to load the inner contents of a div only. Any help is greatly appreciated!

EDIT: SOLVED

I used the unwrap method:

parent.load(href + ' #' + ident + '', function() {
    $('#'+ident+' > div').children().unwrap();
});
  • 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-22T22:42:54+00:00Added an answer on May 22, 2026 at 10:42 pm

    You can do this fairly easily if you don’t mind using $.get and doing the loading parts by hand, something like this:

    $.get(href, function(html) {
        $('#somediv').html(
            $(html).find('#foo').html()
        );
    });
    

    This grabs the full chunk of HTML from href using $.get and then, in the success callback, we find the id="foo" element inside the whole pile of HTML, extract its content with .html() and then copy thing into #somediv with the mutator form of .html().

    If you know that #foo will only contain <div> children, then you could try this:

    $('#somediv').load(href + ' #foo > div');
    

    I’m not certain that this will work and I don’t have a decent test case set up but the .load documentation indicates that it should work. If #foo doesn’t contain only <div>s then you’ll have to come up with something else to use with the child selector (>). Of course, if #foo contains text that isn’t wrapped in an element, then I think you’re stuck with the $.get approach above.

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

Sidebar

Related Questions

Lets say I have this code: <?php class hello { var $greeting = hello;
Lets say i have this array of movie directors: var directors = ['Woody Allen',
Lets say I have this data set... var a = [5,6,7]; var b =
lets say i have this variable : ... Somekindofobject var = new Somekindofobject(); ...
Lets say i have this - for() { //this is a for-each loop try
Lets say I have this array, int[] numbers = {1, 3, 4, 9, 2};
So lets say I have this interface: public interface IBox { public void setSize(int
Lets say I have an array like this: string [] Filelist = ... I
Lets say I have a string COLIN. The numeric value of this string would
This is a contrived example, but lets say I have declared objects: CustomObj fooObj;

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.