user2798091
user2798091

Reputation: 606

Default active jQuery Tab

I am using the following markup for tabs and I would like to make tab-0 to be the default active tab on page load. How do I go about it?

 <div class="gdl-tab">
  <ul class="gdl-tab-title">
   <li><a data-tab="tab-0">ITEM_TITLE1 </a></li>
   <li><a data-tab="tab-1">ITEM_TITLE1</a></li>
  </ul>
 <div class="clear"></div>

 <ul class="gdl-tab-content"><li data-tab="tab-0">ADD_CONTENT_HERE</li><li data-tab="tab-1">ADD_CONTENT_HERE</li><li data-tab="tab-2">ADD_CONTENT_HERE</li>
 </ul>

Upvotes: 1

Views: 104

Answers (1)

mayrs
mayrs

Reputation: 2377

If you are using jQuery UI Tabs then the first tab in the markup is already opened on default.

You can also set the active tab programatically if you wan't to be completely sure that the first tab is opened.

jQuery(document).ready(function() {
    // setter
    $(".selector").tabs("option", "active", 0); //note that the number of tabs is zero based.
});

Upvotes: 1

Related Questions