【问题标题】:jQuery effect() and animate() methods at the same timejQuery effect() 和 animate() 方法同时使用
【发布时间】:2013-08-29 15:13:47
【问题描述】:
我需要同时摇动 div 并为其背景颜色设置动画。
这是 JSFiddle 示例:http://jsfiddle.net/EUz4z/
$("#test").effect("shake", {}, 500 ).css("background-color","red").animate({backgroundColor: old_bg}, 500 );
})
【问题讨论】:
标签:
jquery
jquery-animate
shake
【解决方案1】:
您可以使用queue: false 选项:
http://jsfiddle.net/ysFcD/
$(document).ready(function(){
$("#but").click(function(){
old_bg=$("#test").css("background-color");
$("#test").effect("shake", { }, 500 )
.css("background-color","red")
.animate({backgroundColor: old_bg}, {duration: 500, queue: false } );
})
});