JQuery Ajax Help -


i have page on site loads html via ajax. jquery is:

$(document).ready(function() { $('.projects a').click(function(event) {     $('#work').load(this.href);     event.preventdefault(); }); 

});

and html is:

<div class="projects">     <a href="work/link.html" title="blah" id="blah">blah</a>      <a href="work/link1.html" title="blah" id="blah">blah</a>      <a href="work/link2.html" title="blah" id="blah">blah</a> </div> 

this works fine requirements have changed pull area of page i'm loading #work div. when .project clicked load contents of #this div this.href #work. can point me in right direction?

take @ loading page fragments section. can target sections of page loaded adding selector url string.

the .load() method, unlike $.get(), allows specify portion of remote document inserted. achieved special syntax url parameter. if 1 or more space characters included in string, portion of string following first space assumed jquery selector determines content loaded.

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

when method executes, retrieves content of ajax/test.html, jquery parses returned document find element id of container. element, along contents, inserted element id of result, , rest of retrieved document discarded.

$('#work').load(this.href + ' #this'); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -