2

I use $().offset().top to get the distance between the selected element to the top of the document and log the value inside of scroll event. The code looks like following

$('.element').scroll(function() {
    console.log($('.another-element').offset().top);
});

As a result, I am getting like 1939, 1929, 1920, 1912, 1905, 1899 instead of 1939, 1938, 1937, 1936,1935 and etc.It looks like skipping some value.

How I can get the decrement or increment the top value when scroll?

eded
  • 3,778
  • 8
  • 28
  • 42

0 Answers0