Dejan.S
Dejan.S

Reputation: 19118

Using the select on jquery tabs?

Hi I want to perform a task when I click a specific tab, let's say #tab-2. how is that done? I don't understand the documentation on the jquery site.

I know how it's done on all tabs but not just one

Upvotes: 0

Views: 166

Answers (2)

Jeriko
Jeriko

Reputation: 6637

like this:

$("#tab-2").click(function() {
 //do something
});

?

Upvotes: 1

Nick Craver
Nick Craver

Reputation: 630359

You can do it like this, just check the tab ID:

$( ".selector" ).tabs({
   select: function(event, ui) {
     if(ui.tab.href == "#tab-2") { // or ui.panel.id == "tab-2"
       //do something...
     }
   }
});

You can see what all elements are available on the passed ui argument here, ui.tab is the selected tab link (the <a>), ui.panel is the selected tab itself (the <div>).

Upvotes: 4

Related Questions