admin管理员组

文章数量:1302419

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?

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?

Share Improve this question edited Mar 17, 2013 at 9:58 Ram 145k16 gold badges172 silver badges200 bronze badges asked Mar 17, 2013 at 9:50 AzeemAzeem 2,92418 gold badges56 silver badges89 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

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
});
$("selector").tabs("option", {
    "selected": 1,
    "disabled": [0]
});​

本文标签: javascriptJquery tabs controlhow to select tabStack Overflow