一个简单的jQuery Slideshow效果 (转)
下面是一个jQuery Slideshow效果,用了一种很不错的思路。请看代码:
<div id="slideshow">
<img src="img/img1.jpg" alt="" class="active" />
<img src="img/img2.jpg" alt="" />
<img src="img/img3.jpg" alt="" />
</div>#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
}
#slideshow IMG.active {
z-index:10;
}
#slideshow IMG.last-active {
z-index:9;
} function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 );
});大家细细品味吧。
原文地址:http://jonraasch.com/blog/a-simple-jquery-slideshow
相关推荐
zhangpeng 2014-01-10
lkj0 2014-01-10
PHP淮北PHP00网 2017-02-13
xiongfeng 2015-12-10
Xrapido 2013-02-20
87951536 2012-10-31
jiejieyuy 2012-06-20
zhaoxinglei00 2013-02-06
越前 2009-01-07
PHP100 2019-03-28