Jquery 如何运行动画&x2B;一次回调函数
我希望我的函数运行一次,因此h1元素将转到45px一次,然后使用回调函数(将不透明度更改为0.2)。同样的道理也适用于mouseoutJquery 如何运行动画&x2B;一次回调函数,jquery,function,callback,Jquery,Function,Callback,我希望我的函数运行一次,因此h1元素将转到45px一次,然后使用回调函数(将不透明度更改为0.2)。同样的道理也适用于mouseout $("article.recensie").mouseover(function () { // vraag a $("article.recensie h1").animate({ fontSize: '45px' }, 500, function () { $("article.recensie").animate({
$("article.recensie").mouseover(function () { // vraag a
$("article.recensie h1").animate({
fontSize: '45px'
}, 500,
function () {
$("article.recensie").animate({
opacity: '0.2'
}, 500);
})
});
$("article.recensie").mouseout(function () {
$("article.recensie h1").animate({
fontSize: '40px'
}, 250,
function () {
$("article.recensie").animate({
opacity: '1'
}, 500);
})
});
如果您只想设置css属性的动画,我建议您使用CSS3而不是jQuery 此处的示例和说明: 此处的工作示例:
你能描述一下你当前的代码中哪些是有效的,哪些是无效的吗?整个代码都是有效的,但问题是,当我将鼠标悬停在上面一次时,它会继续执行动画,而不是执行一次。你的代码对我有效,请检查。
article.recensie {
background-color: red;
opacity: 1;
font-size: 40px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
article.recensie:hover {
opacity: 0.2;
font-size: 45px;
}