Go to an element on page using jQuery.
// @params
// ms - milliseconds
// top - padding from top after scrolling to the element
(function(jQuery) {
jQuery.fn.goTo = function(ms, top) {
if (top == null) {
top = 10;
}
$('html, body').animate({
scrollTop: $(this).offset().top - top + 'px'
}, ms);
return this;
};
})(jQuery);
Usage
$(selector).goTo(500);
$(selector).goTo(500, 10);