我有一個圖像滑塊。隨機圖像滑塊(JS)
不幸的是, 圖像滑塊卡在第二個圖像上。
我希望圖像滑塊在無限循環中循環顯示圖像。
我該怎麼做?
這裏是我的jsfiddle:
http://jsfiddle.net/rAqcP/248/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
JS代碼
$(document).ready(function() {
//$('.slider #1').show({right:'0'}, 500);
$('.slider #1').show('slide',{direction:'right'},500);
$('.slider #1').delay(5500).hide('slide',{direction:'left'},500);
var sliderTotalImg = $('.slider img').size();
var counterIndex = 2;
setInterval(function() {
//$('.slider #' + counterIndex).show({right:'0'}, 500);
$('.slider #' + counterIndex).show('slide',{direction:'right'},500);
$('.slider #' + counterIndex).delay(5500).hide('slide',{direction:'left'},500);
if(count==slidecount){
count=1;
}else{
count=count+1;
}
},6500);});
DIV CODE
<div class = "slider">
<img id="1" src="http://www.gohatchmyegg.com/wp-content/themes/BLANK-Theme/images/Pokemon/001.png"/>
<img id="2" src="http://www.gohatchmyegg.com/wp-content/themes/BLANK-Theme/images/Pokemon/002.png"/>
<img id="3" src="http://www.gohatchmyegg.com/wp-content/themes/BLANK-Theme/images/Pokemon/003.png"/>
<img id="4" src="http://www.gohatchmyegg.com/wp-content/themes/BLANK-Theme/images/Pokemon/004.png"/>
</div>
CSS代碼
.slider {
width: 20%;
height: 30%;
overflow:hidden;
border: 1px solid black;
background-image:url("http://test.softvex.com/Slider/Img/loading.gif");
background-repeat:no-repeat;
background-position:center;
}
.slider img {
display:none;
}
哪一部分是隨機的? – Li357
如果您打算將我們指向JSFiddle,它應該是功能性的(即應該顯示問題)。你的JSFiddle不是。 – Makyen
修正:http://jsfiddle.net/rAqcP/248/ –