在 jQuery UI 选项卡中设置默认选项卡
我有一个只有基本 HTML 表格的月历,每个月都在一个 jQuery UI 选项卡选项卡中.如何更改默认加载的 jQuery UI 选项卡?我想在导航中按顺序排列月份,但在页面加载时显示当前月份.
I have a monthly calendar with just basic HTML tables, with each month in a jQuery UI tabs tab. How can I change which jQuery UI tab is loaded by default? I want to keep the months in order in the navigation, but have the current month show on page load.
更新
自从我的原始答案和 jQuery 1.9 发布以来,API 发生了变化.首选方法是使用 redreinard 的答案 中提到的 active
选项:
The API has changed since my original answer and the release of jQuery 1.9. The preferred approach is to use the active
option as mentioned in redreinard's answer:
$('selector').tabs({ active: index });
旧方法(jQuery 1.9 之前)
根据 JqueryUI 选项卡上的文档,您可以通过使用可用的 select
函数,如以下任一方法所示:
According to the documentation on the JqueryUI Tabs, you could set this by using the available select
function as seen in either the approaches below :
// index will be the index of the tab that you wish to select
$('selector').tabs( "select" , index )
$('selector').tabs({ selected: index });