Min's blog

I choose to see the beauties in the world.

导航

背景淡入淡出切换

Posted on 2018-03-29 16:05  Min77  阅读(153)  评论(0编辑  收藏  举报
//图片简单切换:$('xxx').imgtransition({speed: 3000, animate: 1000});
$.fn.imgtransition = function(o){
var defaults = {
speed : 5000,
animate : 1000
};
o = $.extend(defaults, o);
return this.each(function(){
var arr_e = $("li", this);
arr_e.css({position: "absolute"});
arr_e.parent().css({margin: "0", padding: "0", "list-style": "none", overflow: "hidden"});
function shownext(){
var active = arr_e.filter(".active").length ? arr_e.filter(".active") : arr_e.first();
var next = active.next().length ? active.next() : arr_e.first();
active.css({"z-index": 9});
next.css({opacity: 0.0, "z-index": 10}).addClass('active').animate({opacity: 1.0}, o.animate, function(){
active.removeClass('active').css({"z-index": 8});
});
}

arr_e.first().css({"z-index": 9});
setInterval(function(){
shownext();
},o.speed);
});
};