snkranya
snkranya

Reputation: 43

How to get selected tabs id using jquery

I want to get selected tabs id only if I click on the tabs not click inside the tabs. How do it using jquery version 1.9.1? fiddle:http://jsfiddle.net/tbEq6/240/

Js:

$(function() {
$( "#tabs" ).tabs(); 
$("#tabs").click(function(e){ 
      alert($("#tabs .ui-tabs-panel:visible").attr("id"));
}); 
});

Upvotes: 0

Views: 27

Answers (1)

Zenoo
Zenoo

Reputation: 12880

You need to change the element your click handler is attached to to the header of your tab .ui-tabs-anchor :

$(".ui-tabs-anchor").click(function(e){ 
      alert($("#tabs .ui-tabs-panel:visible").attr("id"));
}); 

Upvotes: 1

Related Questions