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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:17:31+00:00 2026-05-15T22:17:31+00:00

HTML code: div id=updatePanel>​ jQuery code: var data=[1, 2, 3, 4, 5, 6, 7,

  • 0

HTML code:

div id="updatePanel">​

jQuery code:

var data=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

$.each(data, function(index, value) {
  setTimeout(function(){ 
     $('#updatePanel').text(index);     
  }, 5000 ); 
}); 

I want the updatePanel div content to be updated every 5 seconds. It should be 1 then wait 5 seconds, display 2, wait for another 5 seconds……

It doesn’t work like what i expected. It waits for 5 seconds and display 9.

See the demo here:
http://jsfiddle.net/vc7qB/4/

  • 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-15T22:17:31+00:00Added an answer on May 15, 2026 at 10:17 pm

    Change the }, 5000 ); to }, 5000*index );

    This will make each item to wait 5 seconds more than the previous …

    Keep in mind that all the timeouts get created at the same time, but with different delay times..

    It would be better to start with a single timeout and at each execution create the next one ..

    like this

    var data=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    
        function update(idx){
            setTimeout(function(){
            $('#updatePanel').text( data[idx] );
            if (idx < data.length - 1)
                update(idx+1);
            },1000);
        }
    
    update(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML code: <div class=clearfix style=color: #555 style=display:block; > <input type=text id=id_site placeholder=nom-du-site style=width: 245px;
In a DIV I place some text/html code which get loaded from a database.
My html code is: <div title=test class=xyz>Tesing</div> I want it to look like: <a
My HTML code goes like this: <div id=single><br><br> 1) effew<br> <input name=answer0 id=answer0 value=1
My anchor tag is not working here is my code : $('.tree div').click(function(){ var
the html code: <div class=fr_search> <select class=search_l onchange=selectSearch(select)> <option value=0>whole site search</option> <option value=1>google
HTML code: <div class=goleft> AD 300x250 size </div> <div class=itemImageBlock goleft> <span class=itemImage> <img
The html code is pasted into this url http://jsfiddle.net/nzYjV/ The div (id=input) contains the
my html code <div id=content_main></div> css #content_main { width:1024px; height:150px; background:url('../images/Orange.jpg'); background-repeat:no-repeat; background-size:1024px 150px;
Consider the following html code: <div id='x'><div id='y'>Y content</div>X content</div> I'd like to extract

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.