我想从白到搏动到另一种颜色跳动,但我不知道如何添加颜色,这种代码jQuery的不同颜色
<script>
$(document).ready(function() {
$("#white36").click(function() {
$('#book').effect("pulsate", { times:3000 }, 500);
});
});
</script>
我想从白到搏动到另一种颜色跳动,但我不知道如何添加颜色,这种代码jQuery的不同颜色
<script>
$(document).ready(function() {
$("#white36").click(function() {
$('#book').effect("pulsate", { times:3000 }, 500);
});
});
</script>
搏动只改变一个元素,而不是颜色的德透明度。你可以在元素下面放一个白色背景的元素来得到你想要的。
像: <div style="background:#ffffff;"><div id="my_elem" style="#006600"></div></div>
我真的希望它从白色到红色脉动,所以我试图找出是否使用“.animate”来改变颜色 – user2097812 2013-03-06 00:21:33
,你可以重新创建你想使用动画这样的脉冲效应:
$(document).ready(function() {
$('#white36').click(function() {
$('#book').animate({
background-color: 'red',
}, 300).animate({
background-color: 'white',
}, 300).animate({
background-color: 'red',
}, 300);
});
});
,但脉冲不在该代码中,因此它不会脉动 – user2097812 2013-03-06 00:43:54
上面的代码有什么问题并不是没有'.effect('pulsate'')这个事实,但是你不能创建背景颜色的动画,我错误地认为你可以实现这一点,你将需要使用$。颜色()可以在这里找到: https://github.com/jquery/jquery-color – Jake 2013-03-06 00:50:32
的一些想法:
$(document).ready(function() {
$("#white36").click(function() {
$("#book").animate({
width: "50%",
opacity: 0.3,
fontSize: "3em",
borderWidth: "10px",
color: "black",
backgroundColor: "green"
}, 1500);
});
});
编辑:只是想跑上面的代码并且在指定背景颜色时不起作用。如果我没有这个参数运行它,但它工作正常。猜猜它的马车,因为我试图与这两个“背景色”和“的backgroundColor”
你将需要这个插件与jQuery动画的颜色(它不存在是默认): http://www.bitstorm.org/jquery/color-animation/
那么你可以做类似这样的事情:
var pulsateInterval = null, i = 0;
$(document).ready(function() {
$('#white36').click(function() {
// set interval to pulsate every 1500ms
pulsateInterval = setInterval(function(){
// animate back and forth
$('#book').animate({
background-color: 'red',
}, 500).animate({
background-color: 'white',
}, 500);
i++;
// stop at 3000 pulsations
if(i == 3000){
clearInterval(pulsateInterval);
}
}, 1500);
});
});
+1好答案。 – Jake 2013-03-06 00:54:41
我查看您的个人资料,并询问3次关于同一问题。我提出了这个问题。 – WooCaSh 2013-03-06 01:06:55