在我的單個產品頁面上,我有一個按鈕,我想在單擊特定按鈕時打開名為“描述”的默認產品選項卡id="cely-popis"。僅當另一個選項卡處于活動狀態而不是“解密”時才應執行此操作。
$("#cely-popis").click(function() {
$('html, body').animate({
scrollTop: $("#tab-description").offset().top - 64
}, 2000);
$('.nav-link[href=tab-description]').trigger('click');
});
uj5u.com熱心網友回復:
我找到了一個解決方案:
$('#cely-popis').click(function(e) {
e.preventDefault();
// smooth scroll to section
$('html, body').animate({
scrollTop: $('#tabs-container').offset().top - 32
}, 2000);
// add "active" class
$('.wc-tabs li a').each(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
}
});
$('.wc-tabs li#tab-title-description a').addClass('active');
$('#tab-description').addClass('active');
$('.woocommerce-Tabs-panel').css('display', 'none');
$('#tab-description').css('display','block');
});
uj5u.com熱心網友回復:
您可以使用此行定位描述選項卡鏈接。
$('a[href="#tab-description"]').trigger('click')
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/422571.html
標籤:
