Why does my imageIndex keep returning -1;
$(function(){
//rotateImages();
setInterval("rotateImages()", 4000);
});
var imageIndex = 0;
var currentPhoto = $("#photoShow div.current");
function rotateImages(){
var max = $("#photoShow div").length;
imageIndex = currentPhoto.index();
console.log(imageIndex + " :: "+ (max - 1));
}
HTML :
<body>
<div id="photoShow">
<div class="current">
<img src="images/Grass.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="images/Leaf.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="images/Spring.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
<div>
<img src="images/Water.jpg" alt="Photo Gallery" width="400" height="400" class="gallery" />
</div>
</div>
0for me, which is correct.