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 9267093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:28:11+00:00 2026-06-18T14:28:11+00:00

I have the below code with the if condition if(oldMembership++ <= newMembership) { var

  • 0

I have the below code with the if condition

if(oldMembership++ <= newMembership) {
    var digit;
    $('ul#indexSiteCounterBottom').empty();

    for(i = 0; i < 9; i++) {
        if(membership.toString()[i] == '_') {
            digit = '&nbsp;';
        } else {
            digit = membership.toString()[i];
        }

        $('ul#indexSiteCounterBottom').append('<li>'+digit+'</li>');
        $('ul#indexSiteCounterBottom li:nth-child(3n)').addClass('extra-margin');
    }
}

If the ‘if’ condition is meet the rest of the code is run.

I want to be able to slow the running of the below code by around 500ms for each loop of the ‘if’.

I’ve tried to put in setInterval and setTimeout but I haven’t used them before and the ‘if’ condition completed all loops instantly.

How can I add setInterval or SetTimeout to this so each ‘if’ loop is delayed by 500ms? Once the ‘if’ condition is meet it should drop out of the timer/if condition.

thankyou very much…

  • 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-06-18T14:28:13+00:00Added an answer on June 18, 2026 at 2:28 pm

    I think this can resolve your problem…

    function execute_if_membership(){
        setTimeout(function(){
            var digit;
            $('ul#indexSiteCounterBottom').empty();
    
            for(i = 0; i < 9; i++) {
                if(membership.toString()[i] == '_') {
                    digit = '&nbsp;';
                } else {
                    digit = membership.toString()[i];
                }
    
                $('ul#indexSiteCounterBottom').append('<li>'+digit+'</li>');
                $('ul#indexSiteCounterBottom li:nth-child(3n)').addClass('extra-margin');
            }
    
            // Execute again if needed
            if(oldMembership++ <= newMembership) {execute_if_membership();}
            else{ /* what to do else? maybe call another function */ }
        },500);
    }
    
    // execute by the first time
    if(oldMembership++ <= newMembership) {execute_if_membership();}
    

     

    EDIT: With this code you call the function by the first time. Function wait 500 ms and execute, in the final of the function, it checks if need to call another time (loop) and if needed it executes again. If you want to execute some code after that, you need to put it inside the ELSE of condition, because if you put another code below, it will be executed without wait. That’s because setTimeout and setInterval makes the code asynchronous and continues to execute the code.

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

Sidebar

Related Questions

Say if I have the code below, it's bascially determining some condition is matched
Imagine that we have below code public class test { public void Condition(x,y) {
I have below condition in my C# 2.0. There is some VbScript code: For
I have the below condition, Can someone please help: if(checkcondition){ --------(A) ... some code
i have below code and cant check if condition ... how can i solve
I have this code below and the if ((DateTime)DataReader[0] > DateTime.Now) condition returns false
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below code: class Program { static void Main(string[] args) { Task[] tasks
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have below code behind in c# if (Session[cmpDictionaryTitle]!= null) { downloadLinks.Text += @<li><a

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.