1
我有我的jQuery滑块 的前一个按钮,当我点击下一个按钮它的工作正常,但前一个按钮没有得到以前的元素,我没有这个问题,我不知道为什么 !!这是我的代码jQuery Slider上一个按钮不能正常工作
HTML:
<div class="sliderContent">
<figure>Img here</figure>
<h3>Title here!</h3>
</div>
<div class="sliderContent">
<figure>Img here</figure>
<h3>Title here!</h3>
</div>
<div class="sliderContent">
<figure>Img here</figure>
<h3>Title here!</h3>
</div>
<div class="sliderContent">
<figure>Img here</figure>
<h3>Title here!</h3>
</div>
<div class="buttons">
<div class="prev"></div>
<div class="next"></div>
的jQuery:
$(function(){
sliderInt= 0;
sliderNext = 1;
count = $(".sliderContent").length -1 ;
$(".sliderContent h3").hide().fadeIn(1200);
$(".sliderContent").eq(sliderInt).fadeIn(500);
$(".prev").click(function(){
$(".sliderContent").fadeOut(500);
$(".sliderContent").eq(sliderNext).fadeIn(500);
sliderNext = sliderNext -1 ;
if(sliderNext < 0) {
sliderNext = count ;
}
}); });
我删除一个按钮的代码只是为了检查,如果问题是从这一
可以拨弄它,请 – Parithiban
比如我有5个格,我想他们滑动..所以数= 5 -1 = 4 ..我这样做是因为.eq()从0开始而不是从1开始..当我点击下一个按钮滑块可以正常工作..但是上一个按钮..它会得到一个不需要的div(或图像)..这里是代码,所以我的错误在哪里?谢谢 .. –