Home  >  Article  >  Web Front-end  >  JS JQUERY method to realize the scroll bar automatically scrolling to the bottom_jquery

JS JQUERY method to realize the scroll bar automatically scrolling to the bottom_jquery

WBOY
WBOYOriginal
2016-05-16 16:21:121363browse

How to set the scroll bar to automatically scroll to the bottom when the page is loaded:

jQuery:

Copy code The code is as follows:

$(function(){
var h = $(document).height()-$(window).height();
$(document).scrollTop(h);
});

JavaScript:

Copy code The code is as follows:

window.onload = function(){
var h = document.documentElement.scrollHeight || document.body.scrollHeight;
window.scrollTo(h,h);
}

Both of the above two methods can realize the scroll bar automatically scrolling to the end when the page is loaded. Friends, you can choose freely according to your actual needs

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn