我知道我可以获取当前选定标签的索引,但是我可以以某种方式获取当前选定标签的ID(如果ui.panel.id是由标签事件触发的,则等价于...,但不是)标签?我不希望使用索引,因为选项卡的顺序可能会更改.我不希望使用样式标记,因为这些样式可能会在将来的版本中更改.有办法吗?如果没有,我可以以某种方式使用索引来访问它吗(甚至可以先访问面板对象)?还有其他想法吗?
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 event...but it's not) of the currently selected tab? I'd prefer not to use the index because ordering of the tabs might change. I prefer not to use the style markups as those may change in future releases. Is there a method for this? If not, can I somehow use the index to access this (maybe even by accessing the panel object first)? Any other ideas?
推荐答案您可以使用 :visible伪选择器定位到可见面板:
You can use the :visible pseudo-selector to target the visible panel:
$("#tabs .ui-tabs-panel:visible").attr("id");值得注意的是,您可以从 activate 事件:
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); } });更多推荐
需要当前为jQuery选项卡选择的选项卡ID
发布评论