Javascript webkit背景上的Jquery.animate()
如何在$(this)上使用Jquery方法.animate()执行以下操作:Javascript webkit背景上的Jquery.animate(),javascript,jquery,jquery-animate,Javascript,Jquery,Jquery Animate,如何在$(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))"); 这很好,但我想定
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动画方法,如下所示:有关动画方法的详细信息,请单击 如果您使用的是较低版本的jQuery(这个方法是从1.0.0版开始发布的,但是有些版本可能不支持它),而动画方法不起作用,那么这是一个替代方案:
$(this).delay(4000).css("background", "-webkit-gradient(linear, left top, left bottom, from(#d70000), to(#679938))");
我使用-webkit关键帧解决了这个问题,并在200毫秒的时间内更改了类。如果有人有一个想法,如何直接将-webkit关键帧与Jquery结合,而不改变类,请写下你的答案。另外,我也不知道为什么.animate()不起作用。如果有人能回答这个问题,我会很感激的
$(this).addClass('akt');
setTimeout(function () { $(this).removeClass('akt'); }, 200);
我无法使用上面的代码让它工作。我正在使用jQuery1.8.4,与此有关吗?尝试使用:
$(this).delay(4000).css(“背景”),webkit gradient(线性,左上,左下,从(#d70000),到(#679938))代码>运气不佳,也尝试过:'$(this.addClass(“akt”);setTimeout(函数(){$(this).removeClass(“ak”;},3000);'看起来我在元素上遇到了一些问题。这是一个输入,type=“button”尝试改用button标记,看看它是如何运行的。
@-webkit-keyframes changeBG {
0% {
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737));
}
50% {
background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#737373));
}
100% {
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737));
}
$(this).addClass('akt');
setTimeout(function () { $(this).removeClass('akt'); }, 200);