Javascript for loop function array -


i'm bit of javascript newbie - i'm trying make function when click button call out single object out of array, in order.

all display "ee".

of course, looping through whole array , assigning each item innerhtml of 1 element - , last 1 stay there , show up.

what want when click button display "aa" when press again display "bb" instead of "aa" , on.

then can't use for-loop, have keep track of counter manually , execute 1 step per invocation of call.

var myarray = ["aa","bb","cc","dd","ee"]; var i=0; function call() {      document.getelementbyid("placediv").innerhtml = myarray[i];     if (i < myarray.length-1)         i++;     else         = 0; // restart, may show error message } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -