Jquery 动画结束后,如何删除类?

Jquery 动画结束后,如何删除类?,jquery,css,animate.css,Jquery,Css,Animate.css,我有jQuery代码,如下所示 $(document).ready(function() { $("#btn").on("click",function(){ $(".article_heading").addClass("animated bounce",function(){ $(".article_heading").removeClass("animated bounce"); }); }); }); 我的问题是animate.css。我不能多次播放

我有jQuery代码,如下所示

$(document).ready(function() {
 $("#btn").on("click",function(){
    $(".article_heading").addClass("animated bounce",function(){
        $(".article_heading").removeClass("animated bounce");
    });
 });
});

我的问题是animate.css。我不能多次播放animate.css,因为这个问题我想用jquery解决,正如你在顶部看到的,但是当我添加动画反弹类时,它必须在动画结束后删除。这是不可能的吗?我无法执行该回调,其他方法可以帮助我吗添加类后,您可以侦听
animationend
事件,然后在启动
animationend
时删除回调中的类和事件侦听器

$("#btn").on("click", function() {
  $(".article_heading").addClass("animated bounce").on('animationend', function (e) {
    $(this).removeClass("animated bounce").off('animationend');
  });
});
您还可以使用来附加事件,以便只触发一次(这意味着不需要在回调中删除处理程序)


太棒了,多亏了你,问题才得以解决:))
$("#btn").on("click", function() {
  $(".article_heading").addClass("animated bounce").one('animationend', function (e) {
    $(this).removeClass("animated bounce");
  });
});