Last active

function to scroll to a specific element in the page

  • Download Gist
1 2 3 4 5 6
//replace #fromA with your button/control and #toB with the target to which you wanna scroll to.
$("#fromA").click(function() {
$("html, body").animate({ scrollTop: $("#toB").offset().top }, 1500);
console.log('executed scrollToElement');
return true;

Thanks, tried heaps of stuff and this is was the quickest and best solution!

Glad to hear that :)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.