【发布时间】:2022-10-14 18:33:56
【问题描述】:
上下文:webflow 有一个内置的下拉菜单,当它打开时,它有一个“w--open”类。在这里,我为类名为“hover-close”的按钮提供了通过删除“w--open”来关闭该下拉菜单的能力。
它可以工作,但是当它关闭时,它会一直滚动到页面顶部,而不是滚动到具有“dropdown-list-9 w-dropdown-list”类的下拉元素。
(function ($) {
'use strict';
$(".hover-close").on("click", function () {
$(".dropdown-list-9.w-dropdown-list").removeClass(" w--open");
$(this).next().slideToggle(300);
$(".dropdown-list-9 w-dropdown-list").not($(this).next()).slideUp("fast");
//Scroll to top for each accordion that is clicked.
// The "180" is the distance from top. The "300" is the scroll speed. The "400" is for the animation delay depending on inner content length.
setTimeout(() => {
$('html').animate({scrollTop: $(this).offset().top-3000}, 300);
}, 400);
});
}(jQuery));
</script>```
【问题讨论】:
-
你能显示你的html代码吗?也许您正在使用
<a href="#"></a>。