我想通过单击Magento2中的定位标记来打开产品页面上的产品标签。 Magento2 CMS版本是2.2.5,下面是代码:
require([
'jquery'
], function($) {
$(document).ready(function() {
$('.mor-link').on('click', function(event) {
// Prevent URL change
console.log('clicked');
event.preventDefault();
// `this` is the clicked <a> tag
$('[data-toggle="switch"][href="' + this.hash + '"]').trigger('click');
});
});
});
<a id="read_more" class="mor-link" href="#new3.tab">Read More...</a>
。
所以我想在这里打开页面底部的FAQ的产品选项卡。您也可以在我的网站上查看:https://uniqaya.com/staging/tinted-sunscreen.html我的脚本可以很好地打开“常见问题解答”选项卡,但是页面正文没有向下滚动到所需的元素位置。请让我知道,我如何实现这一目标。我只想在单击“ Readmore ...”链接后打开FAQ的选项卡,然后将页面主体跳转到该位置。
感谢您,请提供帮助。
您可以在点击处理程序中使用scrollIntoView
方法:
scrollIntoView