1

I am loading content from a url div using jQuery load(). At the moment my code looks like this:

$('#content-slider').load(pageurl + '?rel=tab  #content-slider');

This basically goes to 'pageurl' and obtains #content-slider and loads it into the #content-slider on the current page.

The problem is I'm ending up with a div within a div with the same id:

<div id="content-slider">
    <div id="content-slider">
    </div>
</div>

How can I obtain the html content INSIDE the div but not the div tags.

UPDATE: Apologies if the question is not clear but for those that keep commenting that I shouldn't have duplicate ID... I know! The question is how to overcome this.

2
  • 1
    IDs are Identifiers. Identifiers are unique so it's not good to use one identifier a second time Commented Mar 16, 2013 at 9:46
  • You could have use specific class names for your selector rather than IDs. Remember that elements can have more than one class. Commented May 7, 2013 at 14:01

2 Answers 2

5

You can tell load to get the child nodes of the content slider rather than the slider itself:

$('#content-slider').load(pageurl + '?rel=tab  #content-slider > *');

Live Example | Source

Sign up to request clarification or add additional context in comments.

Comments

0

Alternatively to T.J's answer you could also use .parent

 $("#content-slider").parent().load(pageurl + '?rel=tab  #content-slider');

Updated Example | Source

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.