Solved

JQUERY UI TABS GET ID OF SELECTED

Posted on 2011-10-01
3
242 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
[X]
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
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

622 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