I want when I click load more button content will automatic scroll to the last id. Hmmm
Example
$(document).ready(function(){
$("#loadmorebutton").click(function (){
$('#loadmorebutton').html('');
$.ajax({
url: "loadmore.php?lastid=" + $(".postitem:last").attr("id"),
success: function(html){
if(html){
$("#postswrapper").append(html);
$('#loadmorebutton').html('Load More');
}else{
$('#loadmorebutton').replaceWith('No more posts to show.');
}
}
});
});
});
Live Demo. On the demo I want, after click load more window will scroll to Post no 51 by example.
On Button click, find out the window height
var wh = $(window).height();and apply it to window scrollTop$(window).scrollTop(wh)This will make whatever is on button of the page be first thing on top.