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

相关问题