jQuery how to set first tab active?

后端 未结 4 1445
说谎
说谎 2021-01-21 19:56
 $( \'#xxx\' ).tabs({
select: function(event, ui) { 
var theSelectedTab2 = ui.index;

if (theSelectedTab2  == 0) {
$(\'ul li.ep_s1\').removeClass(\'ep_s1\').addClass(\'e         


        
相关标签:
4条回答
  • 2021-01-21 20:05

    I had to do like this to make it work:

    jQuery( "#xxx" ).tabs({active: 1});
    jQuery( "#xxx" ).tabs("option", "active", 0);
    

    Doing this way trigger the events soon enough

    0 讨论(0)
  • 2021-01-21 20:24

    Perhaps the following line, after the tabs initialize:

    $( '#xxx' ).tabs('select', 0);
    

    Hopefully, it will also trigger the event you want.

    0 讨论(0)
  • 2021-01-21 20:26

    that's what I'd do

    $(function () {
        $("ul.nav-tabs li:first").addClass("active");
        $(".tab-content .tab-pane:first").addClass("active");
    });
    
    0 讨论(0)
  • 2021-01-21 20:29

    Trigger a click event on the first tab after page load?

    Like $('first tab selector').click()

    0 讨论(0)
提交回复
热议问题