// Function/Plugin
$.fn.scrollTo = function () {
return this.each(function () {
$('html, body').animate({
scrollTop: $(this).offset().top
}, 1000);
});
}
// Usage
$("#clickHandler").click(function() {
$("#section2").scrollTo();
});
Credit to Jake Bresnehan at Web Design Weekly for this.
← Cacheable Tweets