如何在 $(this) 上使用 Jquery 方法 .animate() 来实现以下目的:
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737))
我尝试使用:
$(this).css("background", "-webkit-gradient(linear, left top, left bottom, from(#d70000), to(#679938))");
效果很好,但我想定义转换所需的时间
最佳答案
使用 jQuery animate 方法,如下所示:
$(this).animate({"background": "-webkit-gradient(linear, left top, left bottom, from(#d70000), to(#679938))"}, 4000/* Your transition MS here, ex. 4000 */);
有关 animate 方法的更多信息,请单击 here.
如果你使用的是较低版本的 jQuery(嗯,这个方法是从 1.0.0 版本开始发布的,但有些版本可能不支持它),并且 animate 方法不起作用,那么这是一个替代方法:
$(this).delay(4000).css("background", "-webkit-gradient(linear, left top, left bottom, from(#d70000), to(#679938))");
关于javascript - webkit 背景上的 Jquery.animate(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39155213/