我創建了JQuery的這個簡單的推子,基本JQuery的推子
它運行良好,只是,第一圖像變淡了兩次,我該如何解決呢? 這裏是代碼:
$(document).ready(function(){
var count = 0;
var images = ["http://kingofwallpapers.com/fantasy/fantasy-005.jpg",
"https://s-media-cache-ak0.pinimg.com/originals/57/48/b0/5748b075637cb4e085d5d1d1b5990624.jpg",
"http://www.mrwallpaper.com/wallpapers/Fantasy-City.jpg",
"https://galeri14.uludagsozluk.com/855/kad%C4%B1n_1271171.jpg"];
var image = $(".fader");
image.css("background-image","url("+images[count]+")");
setInterval(function(){
image.fadeOut(500, function(){
image.css("background-image","url("+images[count++]+")");
image.fadeIn(500);
});
if(count == images.length)
{
count = 0;
}
},5000);
});
.fader {
position: absolute;
height: 100%;
width: 100%;
left:0;
top:0;
z-index: -99;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fader"></div>