Skip to content

Instantly share code, notes, and snippets.

@harrynewsome
Last active December 2, 2015 10:37
Show Gist options
  • Save harrynewsome/52f67ee8d66f434b1940 to your computer and use it in GitHub Desktop.
Save harrynewsome/52f67ee8d66f434b1940 to your computer and use it in GitHub Desktop.
/*
|--------------------------------------------------------------------------
| With .on Click
|--------------------------------------------------------------------------
*/
$(".parent").on('click', '.element', function() {
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
/*
|--------------------------------------------------------------------------
| With Click
|--------------------------------------------------------------------------
*/
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
/*
|--------------------------------------------------------------------------
| Without Click
|--------------------------------------------------------------------------
*/
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment