Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JQUERY UI TABS GET ID OF SELECTED

Posted on 2011-10-01
3
239 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Asp in script 6 37
Are these icons a web font? 3 21
on window close, not beforeunload 6 17
Javascript 2 22
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

856 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