2016-05-06 63 views
0

在給出的示例中,我使用「.active」和「.inactive」類,但我只想顯示「.active」應用 「.inactive」,我怎樣才能從代碼的情況只顯示類到活動選項卡沒有類休息選項卡

//------ Tabs 
       $('#tabs li:first-child a').addClass('active'); 
     $('#tabs li a:not(:first)').addClass('inactive'); 
       $('.tab-container').hide(); 
       $('.tab-container:first').show(); 

       $('#tabs li a').click(function(){ 
        var t = $(this).attr('id'); 

        if(!$(this).hasClass('active')){ //this is the start of our condition 

      $('#tabs li a').removeClass('active').addClass('inactive');   
        $(this).removeClass('inactive').addClass('active'); 

        $('.tab-container').hide(); 
        $('#'+ t + 'C').fadeIn('slow'); 
       } 
       }); 

JSFiddle Here

+1

你需要https://jsfiddle.net/v78se1b6/嗎? – Satpal

回答

1

這是去掉 「.inactive」 上課!

$('#tabs li:first-child a').addClass('active'); 
    $('.tab-container').hide(); 
    $('.tab-container:first').show(); 
    $('#tabs li a').click(function(){ 
        var t = $(this).attr('id'); 
       if(!$(this).hasClass('active')){        
         $('#tabs li a').removeClass('active');   
         $(this).addClass('active'); 

         $('.tab-container').hide(); 
         $('#'+ t + 'C').fadeIn('slow'); 
        } 
       }); 
+0

謝謝@sandip_rb – Appy

+0

如果工作正常,請標記爲已接受:) @appy – sandiprb

相關問題