am having the following script :
In my ui I will have a text box. If I enter a number in the text box, I need to scroll to the corresponding page number.
In DomI will have some divs with corresponding identifiers. If the user entered the page number as 5. I will check for the 5th offset of the div in dom and get the top value. Using scrollTop, it will scroll to the 5th div.
Here the problem arises after scrolling to the 5th div. If again, enter the page number as 2. The offset of the upper value is negative. Therefore, ScrollTop is moved to the beginning by default.
Here is the fiddle
To reproduce this accurately, go to page number 7 and go back to page number 3 or 4.
source
share