1

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

我的代码有点工作,但由于“acctab”的位置在点击时发生变化,滚动只会带你到它的原始位置(如果这有意义的话)。

$(".acctab").click(function () {

        var target = this,
        $target = $(target);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top
        }, 300, 'swing', function () {
        });

     });
4

1 回答 1

0

您遇到了竞争状况

您想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
        }
    }
});

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

于 2013-09-27T11:21:12.220 回答