How do i get the href value from a link that is loaded with $.get? My scrip always uses the value that used to be in the div, not the value that was loaded afterwards.
The code:
<html>
<body>
<div id="wrapper">
<div id="more">
content
</div>
<div class="paglink">
<a href="/the/url/to/page/1">More</a>
</div>
</div>
<script>
jQuery(document).ready(function($) {
$(".paglink a").click(function(e) {
e.preventDefault();
$.get($(".paglink a").attr('href'), function(data){
$(data).find("#more").appendTo("#more");
$(".paglink").html($(data).find(".paglink").html());
});
});
});
</script>
</body>
</html>
Page that gets loaded:
<html>
<body>
<div id="wrapper">
<div id="more">
content
</div>
<div class="paglink">
<a href="/the/url/to/page/2">More</a>
</div>
</div>
</body>
</html>
In short: what do i have to write instead of
$(".paglink a").attr('href')
to get the value from the freshly loaded link?