Answers for "scroll js"

6

how to smooth scroll in javascript

window.scrollTo({ top: 900, behavior: 'smooth' })
Posted by: Guest on September-22-2020
3

javascript scroll down

window.scrollTo(300, 500);	//X=300 and Y=500
Posted by: Guest on May-22-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
3

js onscroll event

// HTML:
<element onscroll="myScript">
// JavaScript:
object.addEventListener("scroll", myScript)
// or
object.onscroll = function() { /*...*/ }
Posted by: Guest on May-03-2020
1

smooth scrolll to id js

// handle links with @href started with '#' only
$(document).on('click', 'a[href^="#"]', function(e) {
    // target element id
    var id = $(this).attr('href');

    // target element
    var $id = $(id);
    if ($id.length === 0) {
        return;
    }

    // prevent standard hash navigation (avoid blinking in IE)
    e.preventDefault();

    // top position relative to the document
    var pos = $id.offset().top;

    // animated top scrolling
    $('body, html').animate({scrollTop: pos});
});
Posted by: Guest on January-04-2021
0

scroll js

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language