jquery - WooCommerce 中超出了最大调用堆栈大小
问题描述
我在这里有这个 HTML 结构:
<li class="description_tab" id="tab-title-description" role="tab" aria-controls="tab-description">
<a href="#tab-description">Description</a>
</li>
这是我的 JS 函数:
jQuery('body.woocommerce div.product .woocommerce-tabs ul.tabs li').click(function () {
jQuery('a', this).click();
});
我试图做的是检查标签是否被点击。如果这是真的,我将触发单击选项卡的内部。但是当我加载页面时出现错误:
未捕获的 RangeError: 在新的
a.fn.init (jquery-migrate.min.js?ver=1.4 .1:2) 在 HTMLLIElement 的 n (jquery.js?ver=1.12.4:2) 。(custom.js?ver=4.9.8:77) 在 HTMLLIElement.dispatch (jquery.js?ver=1.12.4:3) 在 HTMLLIElement.r.handle (jquery.js?ver=1.12.4:3) 在HTMLAnchorElement 中的 Object.a.event.trigger (jquery-migrate.min.js?ver=1.4.1:2)中的Object.trigger (jquery.js?ver=1.12.4:3) 。(jquery.js?ver=1.12.4:3)
怎么了?
解决方案
这就是它现在的工作方式。工作但有很多代码:
jQuery('body.woocommerce div.product .woocommerce-tabs ul.tabs li').click(function () {
var description = jQuery('.woocommerce-Tabs-panel--description');
var reviews = jQuery('.woocommerce-Tabs-panel--reviews');
if (!jQuery(this).hasClass('active')) {
if (jQuery(this).hasClass('reviews_tab')) {
jQuery('.description_tab').removeClass('active');
jQuery(this).addClass('active');
description.hide();
reviews.show();
} else if (jQuery(this).hasClass('description_tab')) {
jQuery('.reviews_tab').removeClass('active');
jQuery(this).addClass('active');
reviews.hide();
description.show();
}
}
});
我不知道我是否可以做得更好。
推荐阅读
- google-cloud-functions - 如何为 Google Cloud Functions 的 Python 3.8 运行时找到“invoke_user_function”函数
- html - Bacakend 图像未完全加载到 Angular 应用程序的标记中
- angular - IIS 中的 Angular 10 --deploy-url 资产路径
- python - 为什么格式会在单独的 QTextDocuments 之间延续,我该如何防止它?
- python - 如何在 Jenkins 控制台上的数据框中打印单行中的所有列?
- java - 使用一个maven“命令”在同一个项目中运行一个spring-boot应用程序及其黄瓜测试
- elixir - 如何在 Ecto 迁移的执行语句中插入 Elixir 列表?
- django - 在 Django 的模板标签中无法访问用户变量
- python-3.x - Python Mqtt client.loop_forever 如何跳转n行
- angular - Angular 中未显示的属性