首页 > 解决方案 > 当产品详细信息页面有产品库时,滚动到 div 不起作用

问题描述

在 jquery 中滚动顶部不起作用。

我在用

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

单击以观看有关上述情况如何发生的视频。

任何有关这方面的信息将不胜感激。谢谢!

标签: javascriptjquerywordpresswoocommerce

解决方案


你的代码有问题,

尝试这个

var targetTab = $(".tab_custom_ofwc_offer_tab");
    $('html, body').animate({
        scrollTop: $(targetTab).offset().top - '100'
    }, 'fast');

推荐阅读