Jquery 删除用作目标的类

Jquery 删除用作目标的类,jquery,Jquery,考虑到这一点: $('.list-group > a').click(function() { $('html,body').animate({ scrollTop: $(this).offset().top - 32 }, 'slow'); $(this).addClass('active-tab'); $('.glyphicon',this).removeClass('glyphicon-chevron-down').addClass(

考虑到这一点:

$('.list-group > a').click(function() {
    $('html,body').animate({
        scrollTop: $(this).offset().top - 32
    }, 'slow');

    $(this).addClass('active-tab');
    $('.glyphicon',this).removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
});


$(".active-tab").click( function() {
    $(this).removeClass('active-tab');
    $('.glyphicon',this).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
});
在第一次单击时,我添加了
活动选项卡
类,但是如果有人在活动时单击锚点(如标准切换),我希望删除该类。问题是未删除
活动选项卡
类。想法?

如果有人在活动状态下单击锚定(如标准切换),我希望删除该类

这是个胡乱猜测。如果我理解正确的话

您需要使用。您必须使用委托事件方法

i、 e

理想情况下,您应该将
文档
替换为最近的静态容器

范例

$(document).on('click', '.active-tab', function () {
    $(this).removeClass('active-tab');
    $('.glyphicon',this).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
});

现在还不清楚你想要什么你能给我们扔点
HTML
吗?哦,
CSS
也会很可爱…也许是的,就是这样!谢谢!@jonasl,很高兴我能帮上忙。不过我不确定
$(document).on('click', '.active-tab', function () {
    $(this).removeClass('active-tab');
    $('.glyphicon',this).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
});