Reputation: 2924
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
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