2016-05-06 11 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

関連する問題