Set default tab in jQuery UI Tabs

前端 未结 4 1630
眼角桃花
眼角桃花 2020-12-05 12:52

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 t

4条回答
  •  旧巷少年郎
    2020-12-05 13:26

    Update

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

    Older Approach (pre jQuery 1.9)

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

提交回复
热议问题