我已经使用JQuery编写了这些代码行,
var Parent=$('#slider1');
var Li_Navigators=Parent.find('#silder_1part2 ul li');
var ATags=Parent.find('.ClassOfA');
var NextSlide=1;
var NeededTimer=5000;
var Quantity_ATags=ATags.length;
function Slider1() {
if(NextSlide > Quantity_ATags){
NextSlide=1;
}
if(NextSlide < 1){
NextSlide=Quantity_ATags;
}
ATags.hide(150);
ATags.eq(NextSlide-1).fadeIn(150);
Li_Navigators.removeClass('ActiveLI');
Li_Navigators.eq(NextSlide-1).addClass('ActiveLI');
NextSlide++;
}
Slider1();
var ThatInterval=setInterval(Slider1,NeededTimer);
Parent.mouseleave(function(){
clearInterval(ThatInterval);
ThatInterval=setInterval(Slider1,NeededTimer);
});
function NextButton(){
Slider1();
}
function PrevButton(){
NextSlide=NextSlide-2;
Slider1();
}
$('#slider1 #left_button').click(function(){
clearInterval(ThatInterval);
NextButton();
});
$('#slider1 #right_button').click(function(){
clearInterval(ThatInterval);
PrevButton();
});
function SliderButtons(index){
NextSlide=index;
Slider1();
}
$('#slider1 ul li').click(function(){
clearInterval(ThatInterval);
var index=$(this).index();
SliderButtons(index+1);
});
问题是第一张幻灯片一遍又一遍地重复多次并回到其自身,也就是说,在我转到其他选项卡后,甚至当我在PhpStorm上工作时,返回到正常模式:D ,在重复多次后,它又恢复正常并可以正常工作,我怎么做错了? 谢谢您的时间:)