请易 - 第一篇文章!提前幻灯片手动与jQuery
展望修改下面的脚本: http://jonraasch.com/blog/a-simple-jquery-slideshow
爱它的简单,试图找到一种方式来增加提前功能
最好的IMG或DIV - 上点击或链接。
有什么建议吗?
欣赏的帮助
编辑,下面是脚本,这里是一个工作版本的链接:
脚本:
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ($active.length == 0) $active = $('#slideshow IMG:last');
// use this to pull the images in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
// uncomment the 3 lines below to pull the images in random order
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length);
// var $next = $($sibs[ rndNum ]);
$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);
});
风格:
#slideshow {
position:relative;
height:350px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
HTML:
<div id="slideshow">
<img src="image01.jpg" width="262" height="496" border="0" class="active" />
<img src="image02.jpg" width="262" height="496" border="0" />
</div>
谢谢sg3s。我用上面的代码试过了jquery代码,它不会提前也不会循环播放幻灯片 – jsheps
尝试对它进行一些基本的调试。你可以看到更多的伪代码,你没有发布你现在使用的代码(html + images,css,javascript),所以我不能告诉你如何整合它。 – sg3s
易老虎!这是我第一次:)。我使用我正在使用的代码编辑了我的帖子。也许这将有助于?感谢您试用它! – jsheps