Solved

JQUERY UI TABS GET ID OF SELECTED

Posted on 2011-10-01
3
236 Views
Last Modified: 2012-05-12
Hello,
I have a jquery ui tabs loading content via ajax :
<ul>
<li><a href='x1.html' id='tab-a'>bla bla bla</a></li>
<li><a href='x1.html' id='tab-b'>bla bla bla</a></li>
</ul>
I need to get the id (so tab-a or tab-b) of the selected tab. I can get the text with :

$('#tabs').bind('tabsselect', function(event, ui) {
var tab_id = $(ui.tab).text();
alert(tab_id);

but I need the id (not the index)

Thanks for help
0
Comment
Question by:javilmer
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
use : $(ui.tab).closest("li").attr("id")

$('#tabs').bind('tabsselect', function(event, ui) {
var tab_id = $(ui.tab).closest("li").attr("id");
alert(tab_id);

0
 

Author Comment

by:javilmer
Comment Utility
Hi,
Thanks a lot, it does work ! (I just had to put the id in the <li> and not the <href> but this is fine.
Regards
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
my bad, should work too :

with ID on the link :

$('#tabs').bind('tabsselect', function(event, ui) {
var tab_id = $(ui.tab).attr("id"); // or var tab_id = ui.tab.id
alert(tab_id);
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now