I am working on a jQuery function that scrolls until a div is clicked. Right now it will scroll to the top, I was wondering if this could make it scroll to the center $('.scrollit')instead of the top, or perhaps a way to compensate for it with the number of pixels?
$(".playbox").on('click', function () {
$('.scrollit').animate({
scrollTop: $(this).offset().top
}, 1000);
source
share