javascript - How to set up an array of images and loop through them individually -
this simple task more experienced javascript. i'd have array of images , loop through them display each 1 interval of time between each one.
- store images in array: var anarray = [image1, image2, image] (can put images array put src in in array this? when tried treated each string.)
- create loop go through each image in array , fadein each image: (var = 0; <= array.length; i++) don't want want fade in images @ once, want 1 @ time.
- set interval of time: setinterval(functioin() {}, 1000); each image displayed 1 second or many seconds after each other.
i know use plugin, i'm trying learn javascript want avoid taking shortcuts(except of course shortcut of asking on here!)
thanks
var img; for(length) { img[i]=new image(); img[i].src="src"; }
//for storing image array
var count=0; var timerid = setinterval(function() { //fade in image count++; if(count > length)clearinterval(timerid); }, 1000);
better option add image dom on image.onload display:none tag , use loop fade in image 1 one,
Comments
Post a Comment