【发布时间】:2014-04-17 19:42:49
【问题描述】:
我想将背景从彩色变为透明。我有这样的代码:
$('.selector')
.animate({
'background-color' : 'transparent'
}, 2000, function () {
$(this).css({ 'background-color' : '' });
});
这很复杂,因为:
我需要在动画结束后删除
style="",否则style将继续覆盖.hover处理程序设置的CSS 类。所以我用了这个技巧:jQuery - remove style added with .css() function我不知道有什么更简洁的方法可以在 jQuery 中等待效果完成,请参阅:How to wait for effect queue to complete in jQuery call sequence
那么,有没有更简单的解决方案? jQuery效果的一些更巧妙的使用不会那么复杂?
$('.selector')
.animate({
'background-color' : 'transparent'
}, 2000)
.animate({'background-color': ''}, 1);
但在这种情况下它不起作用。
【问题讨论】:
-
@enapupe 你能再详细点吗?随时对此发表答案:-)
标签: javascript jquery css