Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:56:11+00:00 2026-05-25T16:56:11+00:00

How can I take a Javascript for loop display the number of times it

  • 0

How can I take a Javascript for loop display the number of times it has looped with a live count?

for (var i = 0; i < 10; i ++) {
    [ DO FUNCTION HERE ]
    document.getElementsByTagName("span")[3].innerHTML = "Cycles: " + i;
}

I want it to show “Cycles: #” and have the # increment live as it is looping through each function. Similar to a loading screen.
Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:56:12+00:00Added an answer on May 25, 2026 at 4:56 pm

    How about something like this:

    var out = document.getElementsByTagName("span")[3];
    var speed = 1;
    var i = 0;
    function loop() {
        out.innerHTML = "Cycles " + i;
        // do something
        if (++i < 10) {
            setTimeout(loop, speed);
        }
    }
    loop();
    

    If it’s happening too fast to watch the time, just increase speed. If you set speed to 100, you’ll see the counter increment about 10 times per second, depending on how long it takes for your code to execute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which algorithm does the JavaScript Array#sort() function use? I understand that it can take
Can u give me a simple function in vb.net which can take number of
I have a static javascript function that can take 1, 2 or 3 parameters:
I'm trying to create a javascript function that can take a fraction input string
I'm beginning to learn javascript and I wrote an infinite loop <script> while(1==true){ document.write(hello
In JavaScript I can take anyOldObject and add anyOldObject[anyOldProperty]=Test . I could do this
On my site a number of operations can take a long time to complete.
If I have markdown like this: # A Header ``` javascript $(document).ready(function() {}) ```
I can take snapshot of a component. But the problem is the component is
can i get validation on weight which can take decimal values and also integer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.