Answers for "js scroll down"

2

js scroll to bottom

window.scrollTo(0,document.body.scrollHeight);
Posted by: Guest on July-13-2020
3

javascript scroll down

window.scrollTo(300, 500);	//X=300 and Y=500
Posted by: Guest on May-22-2020
1

scroll down up js

var lastScrollTop = 0;

// element should be replaced with the actual target element on which you have applied scroll, use window in case of no target element.
element.addEventListener("scroll", function(){ // or window.addEventListener("scroll"....
   var st = window.pageYOffset || document.documentElement.scrollTop; // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
   if (st > lastScrollTop){
      // downscroll code
   } else {
      // upscroll code
   }
   lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
}, false);
Posted by: Guest on October-24-2020
3

window.scroll

scroll function

window.scroll({
 top: 0, 
 left: 0, 
 behavior: 'smooth' 
});

window.scroll(x-coord, y-coord)
window.scroll(options)
Posted by: Guest on October-15-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language