我有以下脚本 ( from here ) 加载图像并将其设置为背景。它工作正常,但我需要更改什么才能添加多张照片以便它可以作为幻灯片放映?
jQuery:
$(document).ready(function(){
$.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;
}
$('body').smartBackgroundImage('/static/images/temp-bg.jpg');
});
谢谢!
最佳答案
使用 <li>
将您的图像合并到 html 中标签,并用 jquery 格式化它们。这样以后更改它们就更容易了。
关于javascript - 使用 jQuery/css 淡化背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6326040/