0

我认为这很容易,但我就是不明白:

如何在激活 Tab 按钮时删除 FadeIn?

继承人的代码:

$('ul.tab-buttons').each(function(){
  var $active, $content, $links = $(this).find('a');


  $active = $($links.filter('[href="'+location.hash+'"]')[0] || $links[0]);
  $active.addClass('active');
  $content = $($active.attr('href'));


  $links.not($active).each(function () {
    $($(this).attr('href')).hide();
  });


  $(this).on('click', 'a', function(e){
    // Make the old tab inactive.
    $active.removeClass('active');
    $content.hide();

    $active = $(this);
    $content = $($(this).attr('href'));


    $active.addClass('active');
    $content.fadeIn();

    e.preventDefault();
  });
});

我真的无法得到它。它非常重要,因为如果有人点击活动按钮,淡入会重新开始。

谢谢

4

1 回答 1

0

您应该尝试使用 conditional inside on();,如下所示:

if ($(this).hasClass('active') === false){
  // all your previous code 
  // Make the old tab inactive.
     $active.removeClass('active');
     $content.hide(); 
     ...
}

虽然没试过。

于 2013-08-28T16:33:24.417 回答