I have about 20 different images that I want to fade in and out in 4 drawers. I need it to arbitrarily select an image from the list of images and display it.
Boxing example photo1, photo2, photo3, photo4 - their names. They must be individually named as they are completely positioned.
<div id="photo1">
<img src="images/photo.jpg" width="300" height="300" />
<img src="images/photo2.jpg" width="300" height="300" />
<img src="images/photo3.jpg" width="300" height="300" />
<img src="images/photo4.jpg" width="300" height="300" />
<img src="images/photo5.jpg" width="300" height="300" />
</div>
jquery bye
<script type="text/javascript">
var randomnumber=Math.floor(Math.random()*$("#photo1").children().length);
$(function() {
$("#photo1 > img").hide();
setTimeout(function(){
$("#photo1 > img:eq(" + randomnumber + ")").fadeIn();
}, 500);
});
</script>
source
share