我想要的是:
当页面加载时-背景在10秒后变为红色,bgColor变为绿色,并带有淡入淡出动画……10秒后,它再次变为orange....then,变为红色,依此类推。
有人能帮帮忙吗?
发布于 2010-03-02 08:00:00
使用带有更改背景的回调的setinterval:
$("document").ready(function() {
var colours = [ "blue", "orange", "pink" ];
var counter = 0;
function cycleBackground() {
$("body").animate({ backgroundColor: colours[counter] }, 500 );
counter++;
if(counter == colours.length) {
counter = 0;
}
}
setInterval(cycleBackground, 10000);
});如果要在颜色之间平滑循环,则需要使用jQuery UI的animate函数。
https://stackoverflow.com/questions/2359992
复制相似问题