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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:11:50+00:00 2026-06-16T00:11:50+00:00

Fiddle 1 In this fiddle I have created 5 rectangle shapes on a single

  • 0

Fiddle 1

In this fiddle I have created 5 rectangle shapes on a single row using a for loop. Also I have set an interval between each iteration so that instead of directly displaying 5 rectangles together, they are displayed one by one separated by a small interval. This is one part of my solution. And it is working as intended. Now the problem arises in the next part.


What I actually want to do is create multiple rows and that the rectangle should be displayed one by one on first row and then in the same way on the next row. But there is some mistake in my code due to which instead of displaying one rectangle at a time, entire column is displayed at a time.

Here is the Second Fiddle


I hope you understood what I want to do here. How can I correct the code and get the desired result of displaying rectangle one by one and then advancing to the next row?


for (var i = 0; i < 3 ; i++) {
    for (var j = 0; j < 5; j++) {
        window.setTimeout(
        (function (i,j){ 
            return function() {
                var box = paper.rect(j*100,i*50,100,50);
                box.attr({fill:'yellow'});
            }
        })(i,j),j * 500)
    }
}
  • 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-16T00:11:51+00:00Added an answer on June 16, 2026 at 12:11 am

    I think that this solves your problem:

    window.onload = function() {
    
        var ROWS = 3,
            COLS = 5;                
    
        function drawGrid(paper) {
            for (var i = 0; i < ROWS; i += 1) {
                drawRow(i, paper);
            }
        }
    
        function drawRow(row, paper) {
            for (var i = 0; i < COLS; i += 1) {
                drawRect(row, i, paper);
            }
        }
    
        function drawRect(row, col, paper) {
            setTimeout(function () {
                var box = paper.rect(col*100,row*50,100,50);
                box.attr({fill:'yellow'});
            }, (row * COLS * 1000) + (col * 1000));
        }
    
        drawGrid(Raphael(0, 0, 1920, 1000));
    }
    

    ​ ​
    I just made a little refactoring and calculate the timeout depending on the current column and row.

    Here is the fiddle: http://jsfiddle.net/dYRR2/6/

    In other words the timeout should be i * 500 * 5 + j * 500 instead of j * 500.

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

Sidebar

Related Questions

I have created the 3D effect I am after using RotateX in this fiddle:
I have created this Fiddle with this code: This is my problem I want
I have created a fiddle to test this : http://jsfiddle.net/Ninjanoel/X6ShS/ which works fine :(
http://fiddle.jshell.net/kBFU7/2/ In the code, I have created a dynamic table through jQuery. I also
I have created this fiddle for problem as you will see there are three
I am new in JQ. I have created this fiddle here: http://jsfiddle.net/SZ6mY/7/ All I
I have created this fiddle ; The red box animates with CSS left property,
I have this fiddle: http://jsfiddle.net/yub2B/4/ HTML: <input type=text /> <input type=text /> <input type=text
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one
Ok, I have this fiddle http://jsfiddle.net/25J3M/6/ , I want to position the red and

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.