日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

JQ實現將div的滾動條滾動到指定子元素所在的位置

作者:傻的太壞 更新時間: 2024-03-04 編程語言

確保該元素滿足以下幾個條件:

  1. 確保在獲取該元素時,元素一定有高度height;
    2.確保該元素的overflow為auto或者scroll;
    以上兩步缺一不可
function scrollLocation(father, scrollTo) {

    // father.scrollTop(
    //     scrollTo.offset().top - father.offset().top + father.scrollTop()
    // );
    // Or you can animate the scrolling:
    father.animate({
        scrollTop: scrollTo.offset().top - father.offset().top + father.scrollTop()
    }, 1000);
};

var father= $('div'),
    scrollTo= $('#row_8');
scrollLocation(father, scrollTo)

原文鏈接:https://blog.csdn.net/weixin_38897313/article/details/125780319

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新