点击手风琴后进行j查询滚动



我正在移动视图上使用手风琴,正在寻找一种在单击时将访问者滚动到手风琴标题选项卡的方法。

我的代码有点工作,但由于"acctab"的位置在单击时会发生变化,因此滚动只会将您带到其原始位置(如果有意义)。

$(".acctab").click(function () {
        var target = this,
        $target = $(target);
        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 300, 'swing', function () {
        });
     });

您遇到争用条件

您希望在折叠activate构造函数中使用折叠项,而不是观察元素上的单击事件。

$("#tabs").accordion({
    activate: function (event, ui) {
        // Check the active tab
        if (ui.newPanel == 3) { // Or whichever tab you want to apply your action to
            // Your stuff
        }
    }
});

这将在手风琴打开给定选项卡的面板时触发您的回调。

最新更新