JQuery: scroll to the end <li>

I use the following to scroll to the last <li> in an unordered list:

$("html,body").animate({scrollTop: $('ul#cart-items li').offset().top});

How can I change this to scroll to the last <li> in the unordered list, but also shift it about 30 pixels from the top?

+7
source share
2 answers

Have you tried this:

 $("html,body").animate({scrollTop: $('ul#cart-items li:last').offset().top - 30}); 

but + or - 30 at the end to achieve the desired offset?

+9
source
 $("html,body").animate({scrollTop: $('ul#cart-items li:last').offset().top+30}); 

Here it is..

+1
source

All Articles