Hello
I’ve got a webpage where I want to load a content with Ajax without realoading which I did, however I want the code to work on links from the loaded content as well. As far the loaded content seems to behave as a separate document which is not my intention here.
$(function () {
//ajax load of main div content specified in links
// attaching click handler to links
$("a.loadnew").click(function (e) {
// cancel the default behaviour
e.preventDefault();
// get the address of the link
var href = $(this).attr('href');
// getting the desired element for working with it later
var $wrap = $('#ajax-main');
$wrap
// removing old data
.html('')
// slide it up
.slideUp()
// load the remote page
.load(href + ' #content', function () {
// now slide it down
$wrap.slideDown();
});
});
});
and the content html
<div id="content">
<a class="loadnew" href="loadcontent/figure.html">content1</a><br/>
<a class="loadnew" href="loadcontent/speed.html">content2</a><br/>
<a class="loadnew" href="loadcontent/shortspeed.html">content3</a>
</div>
Thx