Good luck...
----Begin HTML Doc----
<html>
<head>
<title>Assign Values From Array Example</title>
</head>
<body>
<div id='OUT'><big><b>Watch me change colors...</b></big></div>
<script>
// Convenience function
function Gid(id) {
return document.getElementById(id);
}
// Number of millisecs to hold color...
var Msecs = 500;
// Array of colors to use...
var Arr = ["blue","green","red","black","orange"];
// Index of next array element to use
var Ind = 0;
// Operation to perform every Msecs
function OnTimeout() {
// Assign color from array
Gid("OUT").style.color = Arr [Ind];
// Advance to next color in array
// and then recycle to beginning...
Ind = (Ind + 1) % Arr.length;
// Call OnTimeout() again in Msecs milliseconds...
window.setTimeout("OnTimeout()", Msecs);
}
// Start the process
OnTimeout();
</script>
</body>
</html>
----Begin HTML Doc----
On Thursday, March 14, 2013 2:51:00 PM UTC-4, yahya Kacem wrote:
Hi everyone, I need to loop through an array and assign each value to the same variable with delay of 100ms I'm using underscore.js for this here's a example plunker.--Thanks in advance.
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.