Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

scroll to element in scrollable div

function scrollInDiv($scrollableDiv, $scrollTo, animate = true) {
    var scrollTo =
      $scrollTo.offset().top +
      $scrollableDiv.scrollTop() -
      $scrollableDiv.offset().top;
    if (animate)
      $scrollableDiv.animate({
        scrollTop: scrollTo,
      });
    else $scrollableDiv.scrollTop(scrollTo);
}
 
PREVIOUS NEXT
Tagged: #scroll #element #scrollable #div
ADD COMMENT
Topic
Name
7+2 =