0
votes

I want to trigger a scroll event handler with scrollTop value of 1px. When I do the following:

$("#myElement").scrollTop = 1;
$("#myElement").scroll();

This doesn't work as it triggers the scroll event handler but with a scrollTop value of 0. Please suggest a way to trigger the scroll event keeping scrollTop 1px.

1

1 Answers

0
votes

If #myElement is scrollable then you code should be,

$("#myElement").scrollTop( 1 );

About jQuery scrollTop