Azeem
Azeem

Reputation: 2924

Jquery tabs control - how to select tab

I have following html to show tabs control of jquery:

<div id="tabs" class="news1">
    <ul>
        <li><a href="#tabs-1">Track</a></li>
        <li><a href="#tabs-2">History</a></li>
   </ul>
   <div id="tabs-1">
   </div>
   <div id="tabs-2">
   </div>
</div>

On page load, following script is written:

<script>
$(function() {
    $( "#tabs" ).tabs();
});
</script>

On page load, tab-1 is selected by default. How can I Programmatically select tab-2 using JavaScript or jQuery?

Upvotes: 3

Views: 13650

Answers (2)

PSR
PSR

Reputation: 40318

$("selector").tabs("option", {
    "selected": 1,
    "disabled": [0]
});​

Upvotes: 0

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 262919

You can specify the active option, which must be set to the zero-based index of the tab you want to activate:

$("#tabs").tabs({
    active: 1
});

Upvotes: 6

Related Questions