首页 > 解决方案 > jQuery Scroll Top 滚动过去所需的 Div

问题描述

我试图使用 scrollTop 函数根据要求滚动到特定的 div,但是,在桌面(谷歌浏览器)上,滚动通常可能超过 div 100px,而在移动设备(safari 和 chrome)上,网页一直滚动至底部。我究竟做错了什么?

此外,在移动设备上 .slideDown() 不会打开 div,但图标确实从加号变为减号

    // physiotherapy department
    if (get_department == 'physiotherapy'){
        jQuery('.accordion').find(`#physiotherapists .link-content`).slideDown();
        jQuery('.accordion').find(`#physiotherapists .link`).addClass('open');
        jQuery('.accordion').find(`#physiotherapists .link a i`).removeClass('fa-plus');
        jQuery('.accordion').find(`#physiotherapists .link a i`).addClass('fa-minus');
        jQuery('html, body').animate({
        scrollTop: jQuery("#physiotherapists").offset().top
    }, 800);
    }

标签: javascriptjqueryscrolltop

解决方案


推荐阅读