Need currently selected tab ID for jQuery tabs

前端 未结 10 2415
臣服心动
臣服心动 2020-12-11 01:10

I know I can get the index of the currently selected tab but can I somehow get to the ID (the equivalent of the ui.panel.id if this were triggered by an tab eve

10条回答
  •  [愿得一人]
    2020-12-11 01:45

    You can use the :visible pseudo-selector to target the visible panel:

    $("#tabs .ui-tabs-panel:visible").attr("id");
    

    It's worth noting that you can retrieve the active tab from the activate event:

    $("#tabs").tabs({
        activate: function (event, ui) {
            console.log(ui.newPanel[0].id);
        }
    });
    

提交回复
热议问题