Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 16:21:12
Original
1373 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template