0

I'm currently working with jQuery-Tabs to simulate a multi-window inputmask. Thus the tabs are variable and users are allowed to add and remove them and the content in those tabs is always the same input-form.

Now I need to select via jQuery some of those fields. The problem is, that I would need to find out which tab is currently selected and use this info in the selector.

Is there a way to identify the currently selected Tab and use this info in a jQuery selector so I can manipulate the right fields?

Iterating through the tabs and checking properties like 'hidden' is not really an option, because it slows down the application significantly.

MADMap
  • 3,132
  • 3
  • 25
  • 31

3 Answers3

0

Write something like this:

var activeTab=0;

$(function(){
    $( ".selector" ).tabs({
       select: function(event, ui) { activeTab=ui.index; }
    });
});

and use activeTab variable wherever you want

Dimitri
  • 6,923
  • 4
  • 35
  • 49
0

Look for the class called "ui-state-active" this will help you to find the active tab

Saligor
  • 78
  • 5
0

Let us say you have the tab container as #myTabs

you can get the id of the selected div using

var id = $("li.ui-tabs-selected a", "#myTabs").attr("href"); // has # as part of the href
$(".myformelement", id).val();
U.P
  • 7,357
  • 7
  • 39
  • 61