javascript - 当产品详细信息页面有产品库时,滚动到 div 不起作用
问题描述
在 jquery 中滚动顶部不起作用。
我在用
- WooCommerce 插件(版本 1.4.9)的优惠。
- WooCommerce(版本 3.4.3)。
- WordPress(版本 4.9.6)。
Offers 插件在商店页面上添加Make offer 按钮,当我们点击它时,它会重定向到产品的 Offers 选项卡。
为此,我们在 js 文件中使用了scrollTop函数。这是代码。
var targetTab = $(".tab_custom_ofwc_offer_tab");
$('html, body').animate({
scrollTop: $(targetTab).offset().top - '100'
}, 'fast');
虽然 WooCommerce 产品页面有产品库,但它不会滚动到那个特定的 div。 请看图片:https ://www.screencast.com/t/BIH5qkKU
这是该问题的视频链接:https ://screenpresso.com/=V3NRf
单击以观看有关上述情况如何发生的视频。
任何有关这方面的信息将不胜感激。谢谢!
解决方案
你的代码有问题,
尝试这个
var targetTab = $(".tab_custom_ofwc_offer_tab");
$('html, body').animate({
scrollTop: $(targetTab).offset().top - '100'
}, 'fast');
推荐阅读
- sql-server - 在另一个会话中执行代码时运行并行事务
- windows - 安装时 Inno Setup 在目标目录中创建的临时 tmp 文件
- python - 极小极大算法理解
- awk - 对于列中的每个唯一值,提取行并单独保存
- reactjs - VS 代码格式化会意外破坏 .js 文件中的代码
- php - PHP在多维数组中的特定索引上查找重复项
- g1ant - 轻松在 G1ant 软件中编写代码
- asterisk - 找到对应的中继通道
- python - 适用于 Linux (WSL 2) 和 Jupyter Lab 的 Windows 子系统:在 Linux 而不是 Windows 的文件系统下保存新的 Jupyter Notebook
- eigen - 特征动态大小的矩阵垂直/水平Linspaced?