Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JQUERY UI TABS GET ID OF SELECTED

Posted on 2011-10-01
3
Medium Priority
?
248 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 83

Accepted Solution

by:
leakim971 earned 2000 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 83

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
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…
Suggested Courses

824 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