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.
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 > *');
Alternatively to TJ's answer you could also use .parent
$("#content-slider").parent().load(pageurl + '?rel=tab #content-slider');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.