Answers for "scroll to ad div"

0

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);
}
Posted by: Guest on February-10-2021
-1

scroll to specific div

$(window).scroll(function() {
    $('html, body').animate({
        scrollTop: $("#myDiv").offset().top
    }, 2000);
});
Posted by: Guest on March-24-2020

Browse Popular Code Answers by Language