简体   繁体   中英

How do I specify what jquery tab to load?

How would I load the second tab in my site instead of the first?

  $('.result').load('ajax/test.html');
  $(document).ready(function() {
      $('#tabs').load('tab2');
  });

below is the some of the HTML...

 <div id="tabs"> 
 <ul> 
 <li
        <%= "overview".equals(fundSection) ? " id=\"current\"" : ""%>>
        <netui-compat:anchor action="switchCardTabs">
            <netui-compat:parameter name="tab" value="overview"/>
            <span><i18n:getMessage messageName="portlets.fundcard.section.overview"/></span>
        </netui-compat:anchor>
    </li> 
    <li<%= "performance".equals(fundSection) ? " id=\"current\"" : ""%>>
        <netui-compat:anchor action="switchCardTabs">
            <netui-compat:parameter name="tab" value="performance"/>
            <span><i18n:getMessage messageName="portlets.fundcard.section.performance"/></span>
        </netui-compat:anchor>
    </li> 
    ....
</div>
</div>

i dont believe its using the jquery UI, is it still possible to manipulate it?

Use the select method.

$('#tabs').tabs('select', 'tab2'); // tab ID
// OR
$('#tabs').tabs('select', 1); // tab index (starts at 0)

假设您正在使用jQuery UI,并且$('#tabs')被初始化为其他地方的jQuery UI tabs对象。

$('#tabs').tabs('select', 1);
$(document).ready(function() {
    $('#tabs').tabs('select', 1);
});

Untested, but should work.

it's simple, jquery UI tab exposes an option called selected you can utilize that on document.ready while initializing the tabs function something like this

  $(document).ready(function() {
  $( "#tabs" ).tabs({ selected: 1 });
  });

please note that tab index are 0 based so for second tab we specified 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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