开发者

auto scroll to bottom of page with jquery

How can i auto scroll to bottom of page with jquery becuase i am requesting xmlhttp to update content of开发者_运维技巧 page


This will work in every case, no need to put a 'ridiculous' number in it:

$(document).scrollTop($(document).height());


To cover all scenarios: Consider scrolling an overflowed div where height is not the same as scrollHeight. (remove the animate part if its not needed):

$('#myDiv').animate({
    scrollTop: $('#myDiv').get(0).scrollHeight
}, 1500);


in my case it's:

 myscroll = $('#myDiv');
  myscroll.scrollTop(myscroll.get(0).scrollHeight);


This Code work for me:-

jQuery("html, body").animate({ scrollTop: jQuery(window).height()}, 1500);


Try the ScrollTo plugin


function scroll(){
  $('html, body').animate({
    scrollTop: $("#footerOfPage").offset().top
  }, 0);
}


auto scroll to bottom of page with jquery (Best):

$(function () {
           $("html, body").animate({
scrollTop: $('html, body').get(0).scrollHeight}, 1000);});

Demo


A lot of the scrollHeight implementations didn't work for me, offsetHeight seemed to do the trick.

Pretty sure that scrollHeight tries to move it to the bottom of the height of the static element, not the height of the scrollable area.

var pane = document.getElementById('pane');
pane.scrollTop = pane.offsetHeight;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜