如何在Jquery中激活选项卡按钮时删除FadeIn?

如何在Jquery中激活选项卡按钮时删除FadeIn?,jquery,Jquery,我认为这很容易,但我就是做不到: 如何在激活选项卡按钮时删除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'); $conten

我认为这很容易,但我就是做不到:

如何在激活选项卡按钮时删除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();
  });
});
我真的搞不懂。这真的很重要,因为如果有人点击活动按钮,fadeIn会重新开始


谢谢

您应该尝试使用conditional inside
on(),类似以下内容:

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

不过我还没试过。

嗯,谢谢,但我试过了,但没有成功。我原以为这很容易,但我快疯了。同时,我发现了一个抛出CSS的解决方案(我只关注Jquery)。所以,我只是在活动CSS类上实现:指针事件:无;游标:默认值;所以,对我来说,任务完成了:)