7

I'm using 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 offset it about 30px from the top?

floatleft
  • 6,243
  • 12
  • 43
  • 53

2 Answers2

11

Have you tried this:

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

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

Kai Qing
  • 18,793
  • 5
  • 39
  • 57
1
$("html,body").animate({scrollTop: $('ul#cart-items li:last').offset().top+30});

Here it is..

Tolga Arican
  • 476
  • 3
  • 14