Easiest JQuery smooth scroll

Coding Jan 21, 2020


The most minimalist way to include smooth scroll in JQuery after an on_click event is triggered. I specifically integrated this in my website.

function go_top() {
    window.scrollTo({
        top: 0,
        behavior: 'smooth'
    });
}

function go_bottom() {
    window.scrollTo({
        top: document.body.scrollHeight,
        behavior: 'smooth'
    });
}
<a onclick="go_top()">Back to top</a>
<a onclick="go_bottom()">Go to bottom</a>

   
See a demo here-

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.