简体   繁体   English

Jquery选项卡控件 - 如何选择选项卡

[英]Jquery tabs control - how to select tab

I have following html to show tabs control of jquery: 我有以下html来显示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. 在页面加载时,默认选择tab-1。 How can I Programmatically select tab-2 using JavaScript or jQuery? 如何使用JavaScript或jQuery以编程方式选择tab-2?

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]
});​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM