所以我试图让这个渐弱的背景动画永远在网页上继续。我该怎么做?这是代码:
$( document ).ready(function() {
// Changing the background js code
console.log('File Loaded! DELETE!!!');
animate();
});
function animate() {
window.setInterval(function(){
window.setTimeout(function(){
$('.content').css('background-image','url(http://crondon.guko.co.uk/wp-content/uploads/2015/11/confetti.jpg)');$('.content').css('transition','background 1s linear');$('.content').css('-webkit-transition','background 1s linear');$('.content').css('-moz-transition','background 1s linear');$('.content').css('-o-transition','background 1s linear');
},3000);
$('.content').css('background-image','url(http://crondon.guko.co.uk/wp-content/uploads/2015/11/bride_groom_baronial_hall1.jpg)');$('.content').css('transition','background 1s linear');$('.content').css('-webkit-transition','background 1s linear');$('.content').css('-moz-transition','background 1s linear');$('.content').css('-o-transition','background 1s linear');
},3000);
animate();
}
答案 0 :(得分:1)
您不在setInterval中使用setTimeouts。我想你正在寻找setInterval的功能。看看https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval。
一个基本的例子(每1000毫秒或1秒重复一次)将是:
setInterval(function() {
// Code to repeat here
}, 1000);