You need to scroll down the page to the number of pixels, which will be calculated by the document.documentelement.clientheight function. How to do it?
|
2 answers
Try this:
var y = $(window).scrollTop(); //твоя текущая позиция $(window).scrollTop(y+150); Detailed example + animation :
$(window).load(function() { $(window).scroll(function() { $('#scroll').fadeIn(200); }); $('#scroll').click(function() { // When button is clicked $('body,html').animate({ scrollTop: 150 // Scroll to 150px of the top }, 500); }); }); body { height: 1500px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> <body> <p> <button id="scroll">Scroll to The Point</button> </p> </body> ps. Questions will be, I can write a detailed example.
- Thanks, but how to make an animated scroll - BedOmar
- @BedOmar I updated my answer by adding an example with animation, you can see if I refused to use
$(window).scrollTop(y+150)in this case. - user192664 pm
|
clientHeight is not a function, but a property, but oh well.
window.scrollTo(0, document.documentElement.clientHeight); |