Answers for "js scroll top animation div"

1

jquery scroll to top of div animate

$("#yourDivID").animate({scrollTop:0}, "smooth");
Posted by: Guest on January-19-2021
0

js animate scroll to the top of the page

function scrollTo(element, to, duration) {
    if (duration <= 0) return;
    var difference = to - element.scrollTop;
    var perTick = difference / duration * 10;

    setTimeout(function() {
        element.scrollTop = element.scrollTop + perTick;
        if (element.scrollTop === to) return;
        scrollTo(element, to, duration - 10);
    }, 10);
}
Posted by: Guest on October-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language