如何使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、跳转关键帧和示例<代码>。