Javascript examples for Array Operation:Array Element
Get array element one by one with timer setTimeout()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// www . j a v a 2s . co m var skins = ["%k", "%m", "%s", "%b"]; var skin; function changeSkin(i) { skin = skins[i = (i && i < skins.length) ? i : 0]; console.log(skin); setTimeout(changeSkin, 1000, ++i); } changeSkin(); } </script> </head> <body> </body> </html>