Scroll to Element

Scroll to a element using JavaScript, selecting time & element.

JavaScript function

function scrollDown(triggerClass, elementToScroll, timeToScroll){
    $(triggerClass).on('click', function(){
        $('html, body').animate({
            scrollTop: ($(elementToScroll).offset().top)
        }, timeToScroll);
    })
}

JavaScript Call

$(document).ready(function () {
    scrollDown('#scroll-down', '.page-content', 1000);
});

HTML

<div id="scroll-down"></div>

Last updated

Copyright 2024 - jseidl.at Julian Seidl