我有一个基本的Jquery Slider的下面的代码,但是这个代码只用类执行一个div:“slide-wrapper”,但我需要一次运行2个或更多的滑块...这是我的完整代码:
HTML:
<!-- SLIDE 1 -->
<div class="slide-wrapper">
<div class="slide">
<a href="#"><img src="images/tmp/adv_left_sup.jpg" width="600" height="100" /></a>
</div>
<div class="slide initial-hide">
<a href="#"><img src="images/tmp/adv_left_sup_2.jpg" width="600" height="100" /></a>
</div>
<div class="slide initial-hide">
<a href="#"><img src="images/tmp/adv_left_sup_3.jpg" width="600" height="100" /></a>
</div>
</div>
<!-- SLIDE 2 -->
<div class="slide-wrapper">
<div class="slide">
<a href="#"><img src="images/tmp/adv_left_sup.jpg" width="600" height="100" /></a>
</div>
<div class="slide initial-hide">
<a href="#"><img src="images/tmp/adv_left_sup_2.jpg" width="600" height="100" /></a>
</div>
<div class="slide initial-hide">
<a href="#"><img src="images/tmp/adv_left_sup_3.jpg" width="600" height="100" /></a>
</div>
</div>
CSS:
.slide-wrapper { position: relative; height: 100px; }
.slide-wrapper div.slide { position: absolute; }
.slide-wrapper .initial-hide { display: none; }
JS:
var currentPosition = 0;
var totalSlides = 0;
$(document).ready(function() {
// slides
totalSlides = $('.slide-wrapper .slide').length;
setTimeout('transition()', 3000);
});
transition = function() {
currentPosition++;
lastPosition = currentPosition - 1;
if (currentPosition == totalSlides)
currentPosition = 0;
if (lastPosition < 0)
lastPosition = totalSlides - 1;
$('.slide-wrapper .slide:eq(' + lastPosition + ')').fadeOut('slow');
$('.slide-wrapper .slide:eq(' + currentPosition + ')').fadeIn('slow');
setTimeout('transition()', 3000);
}
我希望你的帮助,谢谢你 P.D.抱歉我的英文:)
答案 0 :(得分:0)
嗯,我完全不理解(我的英语是不合理的)......
您使用的是jquery-ui slider吗?
检查一下,你可以做滑块和多滑块。
你有一个2个滑块,在某个类名“slide-wrapper”,如何在滑块中转换它?
$('slide-wrapper').slider({...});
你可以拥有很多带有classname slider-wrapper的元素,而且有些人有一个id,ex;
<div class="slide-wrapper" id="slider1">
来自Jquery:
$('#slider1').slider({...});