Solved

JQUERY UI TABS GET ID OF SELECTED

Posted on 2011-10-01
3
238 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
ID: 36897418
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
ID: 36897439
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
ID: 36897449
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

776 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