站点背景图像的JQuery FadeIn效果
我正在尝试使fadeIn()效果对一系列漫游图像起作用。我采用了另一个答案中的一些代码,效果很好,但不幸的是,我无法得到它的衰减效果。我尝试将fadeIn()添加到站点背景图像的JQuery FadeIn效果,jquery,fadein,Jquery,Fadein,我正在尝试使fadeIn()效果对一系列漫游图像起作用。我采用了另一个答案中的一些代码,效果很好,但不幸的是,我无法得到它的衰减效果。我尝试将fadeIn()添加到$(“尝试 $.fn.smartBackgroundImage = function(url){ var t = this; //create an img so the browser will download the image: $('<img />') .att
$(“尝试
$.fn.smartBackgroundImage = function(url){
var t = this;
//create an img so the browser will download the image:
$('<img />')
.attr('src', url)
.load(function(){ //attach onload to set background-image
t.each(function(){
$(this).css('backgroundImage', 'url('+url+')' );
});
});
return this;
}
//10 second Interval
window.setInterval(rotate, 10000);
var counter = 0;
function rotate() {
//Rotage through images 0 - 4
$('html').smartBackgroundImage('assets/background'+counter+'.jpg');
counter == 3? counter = 0 : counter++;
}
$("html").smartBackgroundImage("assets/background" + counter + ",jpg").fadeIn();