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?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
Jonathan Sampson's answer doesn't work anymore. Try...
$("#tabs .ui-tabs-panel:visible").attr("id");
jsFiddle: http://jsfiddle.net/tbEq6/
As I posted in an answer to this question, there are several ways to achieve this.
On the jQuery documents, they propose to do the following to find the index of the currently open tab:
However, this is impractical if you need to do a lot with that tab. Why they don't yet provide a more practical solution of getting the actual element, I'm unsure, however, through use of jQuery there is an easy solution you can create yourself.
In the following code i'll show you just how easy it is to do anything you want with the current tab:
You can use the
:visible
pseudo-selector to target the visible panel:It's worth noting that you can retrieve the active tab from the activate event: