I have an un-ordered list of links in a navigation like so:
<ul class="main-nav-child">
<li><a href="/collections/1">collection one</a></li>
<li><a href="/collections/2">collection two</a></li>
<li><a href="/collections/3">collection three</a></li>
</ul>
When clicked, I'm loading the html output of each link into a container called .main-content
using this snippet:
$('ul.main-nav-child a').bind('click', function(e) {
var url = $(this).attr('href');
$('.main-content').load(url); // load the html response into a DOM element
e.preventDefault(); // stop the browser from following the link
});
Problem: I want to load just the contents from a certain element from the link, not the entire page. Each page has an element called .main-content
and I want to grab that via ajax and display it on the page, again within .main-content
Any guidance on how to filter .load()
would be greatly appreciated.