我正在尝试将fadeIn()效果用于漫游系列图像。我从其他答案中采用了一些效果很好的代码,但不幸的是我无法让它褪色效果。我尝试将fadeIn()添加到$('<img/>').fadeIn().attr
序列中,但似乎无法想出这个......
有什么想法吗?
$.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++;
}
答案 0 :(得分:0)
尝试
$("html").smartBackgroundImage("assets/background" + counter + ",jpg").fadeIn();