Need currently selected tab ID for jQuery tabs

前端 未结 10 2289
臣服心动
臣服心动 2020-12-11 01:10

I know I can get the index of the currently selected tab but can I somehow get to the ID (the equivalent of the ui.panel.id if this were triggered by an tab eve

相关标签:
10条回答
  • 2020-12-11 01:21

    For jQuery UI >= 1.9 you can use ui.newPanel.selector:

    $('#tabs').on('tabactivate', function(event, ui) {
      console.log(ui.newPanel.selector);
    });
    
    0 讨论(0)
  • 2020-12-11 01:25

    After JQuery 1.9 selected is deprecated

    So use

    var active = $( "#jtabs" ).tabs( "option", "active" );

    0 讨论(0)
  • 2020-12-11 01:26

    If you want the id (or actually the href) from the selected tab, you can use eq() to retrieve the jQuery Object.

    You can see an example here: http://jsfiddle.net/svierkant/hpU3T/1/

    0 讨论(0)
  • 2020-12-11 01:31

    This works:

    $('#divName .ui-tabs-panel[aria-hidden="false"]').prop('id');
    
    0 讨论(0)
  • 2020-12-11 01:35

    For jquery version below 1.9:

     <div class="roundedFloatmenu">
            <ul id="unid">
                <li class="titleHover" id="li_search">Search</li>               
                <li class="titleHover" id="li_notes">Notes</li>
                 <li class="titleHover active" id="li_writeback">Writeback</li>         
                <li class="titleHover" id="li_attorney">Attorney</li>
            </ul>
        </div 
    

    And you can find the active tab using:

     jQuery('#unid').find('li.active').attr('id')
    
    0 讨论(0)
  • 2020-12-11 01:37
    $("#tabs .ui-state-active a").attr("id");
    
    0 讨论(0)
提交回复
热议问题