Ich möchte ein Karussell-Looping, wo 1 Bild kommt, verbirgt sich und ein anderes macht das gleiche und so weiter. Das Problem ist, dass ich möchte, dass dies unendlich wiederholt wird, was nicht passiert.Looping passiert nicht in Karussell
$(function(){
//alert(j)
var j=-1;
setInterval(function(){
console.log('hi');
if(j>=$(".carousel .item").length){
console.log("hut");
j = -1;
}
while(j<$(".carousel .item").length){
j++;
console.log("i: "+j);
$(".carousel .item").eq(j-1).hide();
$(".carousel .item").eq(j).show(function(){
alert("hiii");
},200,"linear");
//console.log(j);
}
j=-1;
//console.log(j)
},1200);
})
html:
<div class="carousel">
<div class="item">India</div>
<div class="item">china</div>
<div class="item">Australia</div>
</div>
CSS:
.carousel .item{display: none;}
i resetted die j Variable nach der while-Schleife aber keine Wirkung. Bitte helfen Sie. Danke im Voraus.
Geige: https://jsfiddle.net/fj2r0req/
Dank aravind so viel, es hat mir sehr geholfen. – user3450590