jQuery has a function called scrollTop which can be used to find the number of pixels hidden above the current page view.
I\'m not really sure why, but there is no s
As scrollTop's default behaviour scrolls to 0 when passing a negative value, I did this function that handles scrollTop and simulate a "scrollDown".
If anchor_pos is negative (so it's above my current scroll position), I subtract its value from current scroll position (as it has a negative value, I'm using + sign)
function jumpToAnchor(scrollable_div_selector, anchor_selector)
{
anchor_pos = $(anchor_selector).position().top;
//check if negative number
if (anchor_pos < 0)
{
anchor_pos = $(scrollable_div_selector).scrollTop() + anchor_pos; //anchor_pos is negative, so i'm substracting it
}
$(scrollable_div_selector).scrollTop(anchor_pos);
}