Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to create a time using loop and sleep function(sleep is function of c language) in java script.

What I have tried:

i've tried but could not increase or decrease speed of running loop, so here is problem. kinldy share full source code in java script.
Posted
Updated 20-Jul-16 15:21pm
Comments
Patrice T 20-Jul-16 18:12pm    
No, show your code.
ZurdoDev 25-Jul-16 19:31pm    
It is very unclear what you are asking for.

I guess you want to make an animated clock.
Don't use a loop to animate, use a timer instead. pay attention to the way you set the timer to prevent time sliding.

How To JS Animate[^]

[Update]
Quote:
the reference you've given does not meet my question's reply nor meaning
First of all the wording of your question is not clear. time have no meaning in the context and it is the key word of the question.
Second, you want to apply to JS a solution that doesn't exist in JS.
Third, posting your code would have help understand what you are trying to do, but you didn't.
 
Share this answer
 
v2
Comments
sabhajeetkmr9@gmail.com 25-Jul-16 17:13pm    
the reference you've given does not meet my question's reply nor meaning
check these

Window setInterval() Method[^]
Window setTimeout() Method[^]


C#
var items = [1, 2, 3, 4, 5];
        var time = 1000 // milliseconds        
        var i = 0;
        var loop = window.setInterval(function () { 
            processItem(items[i]);
            i++;
            if (i == items.length)
                clearInterval(loop);
        }, time);

        function processItem(item) // this function wil be called for each item in the array at the  specified time.
        {
            document.getElementById('txtData').value = item;
        }


demo : JSFiddle[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900