有这个基本滑块,但我不能让它工作。现在检查代码很多次,不能看到我的错误.. 有人可以告诉我我错在哪里。
<script type="text/javascript">
var mySlides = new Array('first.gif','second.gif','third.gif','fourth.gif');
var slide = 0;
function showSlide(slideNumber){
slide = slide + slideNumber;
if(slide>mySlides.length - 1){
slide=0;
}
if(slde<0){
slide=mySlides.length - 1;
}
document.displaySlide.src=mySlides[slide];
}
</script>
<body>
<p><img src="first.gif" name="displaySlide"></p>
<input type="button" value="Back" onclick="showSlide(-1);" />
<input type="button" value="Forward" onclick="showSlide(1);" />
答案 0 :(得分:1)
<script type="text/javascript">
var mySlides = new Array('first.gif','second.gif','third.gif','fourth.gif');
var slide = 0;
function showSlide(slideNumber){
slide = parseInt(slide)+parseInt(slideNumber);
if(slide == -1)
{
slide = 0;
}
alert(slide);
if(slide > mySlides.length)
{
slide = mySlides.length;
}
document.displaySlide.src=mySlides[slide];
}
</script>