How to Set Active Tab in jQuery Ui

后端 未结 9 1360
灰色年华
灰色年华 2020-12-08 18:51

Can you please let me know how I can set the active tab in jquery ui with a button click out of the tabs?

I have a button like:



        
相关标签:
9条回答
  • 2020-12-08 18:55

    Just to clarify in complete detail. This is what works with the current version of jQuery Ui

    $( "#tabs" ).tabs( "option", "active", # );
    

    where # is the index of the tab you want to make active.

    0 讨论(0)
  • 2020-12-08 19:02

    Inside your function for the click action use

    $( "#tabs" ).tabs({ active: # });
    

    Where # is replaced by the tab index you want to select.

    0 讨论(0)
  • 2020-12-08 19:03

    Simple jQuery solution - find the <a> element where href="x" and click it:

    $('a[href="#tabs-2"]').click();
    
    0 讨论(0)
  • 2020-12-08 19:06

    just trigger a click, it's work for me:

    $("#tabX").trigger("click");
    
    0 讨论(0)
  • 2020-12-08 19:08

    Inside your function for the click action use

    $( "#tabs" ).tabs({ active: # });
    

    Where # is replaced by the tab index you want to select.

    Edit: change from selected to active, selected is deprecated

    0 讨论(0)
  • 2020-12-08 19:11

    If you want to set the active tab by ID instead of index, you can also use the following:

    $('#tabs').tabs({ active: $('#tabs ul').index($('#tab-101')) });
    
    0 讨论(0)
提交回复
热议问题