javascript - 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);
}
解决方案
推荐阅读
- r - if (n < 0) stop("网络对象不能为负数。") 中的错误:需要 TRUE/FALSE 的缺失值
- discord.js - Discord.js 亵渎过滤器将 hello 检测为坏词
- go - 如何做嵌套的 goroutines
- elixir - 有什么问题:is_number if true do 1 end
- c# - How to assign values to nested class properties?
- dynamic - 为什么给定 2 个参数,TypeError: 正好需要 2 个参数(1 个给定)?
- java - 在Java中采用空格分隔的输入类型
- php - 为什么这个 next_page_link 不能正常工作?
- php - 函数调用返回数组输出的第一个字符
- javascript - 如何使用 OOP JavaScript 重复一个函数