gpt4 book ai didi

jquery - 添加/删除类时 Animate.css 不工作

转载 作者:行者123 更新时间:2023-11-28 10:45:16 25 4
gpt4 key购买 nike

无论出于何种原因,我的 addClass、removeClass 在我的悬停功能中都不起作用。我认为这是一个语法问题,但即使我解决了这个问题,问题仍然存在。请指教。

这是函数

$(".run").hover(function(){
//alert("1");
$(this).addClass("animated infinite");
},
function(){
//alert("2");
$(this).removeClass("animated infinite");
}
);

这是函数的链接 http://jsfiddle.net/galnova/y50wr52n/9/

最佳答案

这是因为您没有切换 bounce 类。

Updated Example

$(".run").hover(function(){
$(this).addClass("animated infinite bounce");
},
function(){
$(this).removeClass("animated infinite bounce");
}
);

显然存在一些跨浏览器的不一致。这在 Chrome 中修复了它。现在它适用于所有支持的浏览器。


你可以完全避免 JS/jQuery 并使用以下内容:

Example Here

.run:hover {
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-name: bounce;
animation-name: bounce;
-webkit-transform-origin: center bottom;
-ms-transform-origin: center bottom;
transform-origin: center bottom;
}

不过,您可能想使用动画速记:

Example Here

.run:hover {
-webkit-animation: bounce 1s infinite both;
animation: bounce 1s infinite both;
-webkit-transform-origin: center bottom;
-ms-transform-origin: center bottom;
transform-origin: center bottom;
}

关于jquery - 添加/删除类时 Animate.css 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28745644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com