繁体   English   中英

jQuery UI,如何预选标签

[英]jQuery UI, how to preselect a tab

我已经读过- 在jquery UI选项卡中预选择启用了ajax的选项卡,并尝试了API文档...

这是最基本的代码... http://jsfiddle.net/Xa2ur/

我希望能够指定选择的选项卡,但是我找不到的语法不起作用。

我最终将传递一个变量,但是如果我无法使硬代码工作,那么采取额外的步骤有什么好处。

任何帮助-以及我为什么没有做的“为什么”,我们深表感谢。

编码

$( function() {
    $( "#tabs" ).tabs({
        beforeLoad: function( event, ui ) {
            ui.jqXHR.error( function() {
                ui.panel.html( "Couldn't load this tab. We'll try to fix this as soon as possible." );
            });
        }
    });
});

-其他代码-

<div id="tabs" >
        <ul>
            <li class="firsttab" ><a href="#tabs-1" >Wedding</a></li>
            <li class="" ><a href="#tabs-2" >Gig Feb 2013</a></li>
            <li class=""><a href="#tabs-3" >Homecoming</a></li>
        </ul>
        <div id="tabs-1" >
            <p>Description: Wedding Info</p>
            <p>photos</p>
        </div>
        <div id="tabs-2" >
            <p>Description: A gig @ TT the Bears</p>
            <p>blog</p>
        </div>
        <div id="tabs-3" >
            Stuff
        </div>
    </div>
    <script>
        $( "#tabs" ).tabs( "option", "active", 2 );
        // i HAVE also tried - $('#tabs').tabs({ selected: "2" });
    </script> 
$( function() {
    $( "#tabs" ).tabs({
        beforeLoad: function( event, ui ) {
            ui.jqXHR.error( function() {
                ui.panel.html( "Couldn't load this tab. We'll try to fix this as soon as possible." );
            });
        },
        active:2
    });
});

暂无
暂无

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

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