Help us understand the problem. What is going on with this article?

jQueryUI:tab選択時に元のスクロール位置を復元する方法

More than 5 years have passed since last update.

以下のように「activeate」と「beforeAvtivate」でスクロール位置の保存・復元を行う。

タブの外枠.tabs({
    activate: function (event, ui) {
        
        var $selectedItem = $(アクティブになった要素);
        if ($selectedItem[0].scrollHeight > 0)
        {
            $selectedItem.scrollTop($selectedItem.data("scrollTop"));
        }
        $selectedItem.data("scrollTop", 0);
    },
    beforeActivate: function (event, ui) {
        var $beforeSelectedItem = $(非アクティブになる要素);
        $beforeSelectedItem.data("scrollTop",$beforeSelectedItem.scrollTop());
    }
});

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away