Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使javascript动画再次工作_Javascript_Html_Jquery_Css - Fatal编程技术网

如何使javascript动画再次工作

如何使javascript动画再次工作,javascript,html,jquery,css,Javascript,Html,Jquery,Css,我有一个触发动画的函数 function jumpAnimation() { $('.array__elem').each(function (index) { $(this).css({ animation: `jump 1s ease-in-out`, 'animation-delay': index * 0.05 + 's', }); }); } 但是,该函数只有在我第一次调用它时才起作用。当我再次调用该函数时,动画不会重新触发。如何实现这

我有一个触发动画的函数

function jumpAnimation() {
  $('.array__elem').each(function (index) {
    $(this).css({
      animation: `jump 1s ease-in-out`,
      'animation-delay': index * 0.05 + 's',
    });
  });
}

但是,该函数只有在我第一次调用它时才起作用。当我再次调用该函数时,动画不会重新触发。如何实现这一点?

尝试添加css,
动画:`jump 1s infinite ease in out`

如果不起作用,您也可以尝试
动画迭代计数:无限

所以看起来应该是这样的

function jumpAnimation() {
  $('.array__elem').each(function (index) {
    $(this).css({
      animation: `jump 1s infinite ease-in-out`,
      'animation-delay': index * 0.05 + 's',
    });
  });
}

动画不应该无限地运行,只有当函数被调用时。@ BrasrGrunWald,我是说,在JS函数中,你可以发布CSS、跳转关键帧和示例<代码>。