0

I have a div with the following CSS properties, in order to have it scroll in place:

height: 746px;
width: 295px;
overflow: auto;
margin-bottom: 11px;
position: relative;

I need to do two seperate things with jQuery:

  1. onclick of a button, scroll the box up by 100px.
  2. upon reaching the bottom of the box when scrolling, fire a function.

I've tried using both .position() and .offset() to get where it is now, but neither are updating the position when it's scrolling. What am I doing wrong?

TH1981
  • 3,105
  • 7
  • 42
  • 78

1 Answers1

0
  1. use the scrollTop property

    $(element).scrollTop($(element).scrollTop()+100);

  2. use the scroll event

    $(element).scroll(function(){ //check the height of the div and the scrollTop value so you know if you are at the bottom and then do some code })

arieljuod
  • 15,460
  • 2
  • 25
  • 36