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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:59:25+00:00 2026-06-07T15:59:25+00:00

I have a two-dimensional array which I get back as JSON from a call.

  • 0

I have a two-dimensional array which I get back as JSON from a call.

and I also have a 3-by-3 div.

as follows:

<div id="type0">
    <div id="image00"></div>
    <div id="image01"></div>
    <div id="image02"></div>
</div><br />

<div id="type1">
    <div id="image10"></div>
    <div id="image11"></div>
    <div id="image12"></div>
</div><br />

<div id="type2">
    <div id="image20"></div>
    <div id="image21"></div>
    <div id="image22"></div>
</div><br />

and i have the loop below to iterate the data.

$.each(res, function (i, tickets) {
     $.each(tickets, function (j, ticket) {

         console.log('i:' + i);
         console.log('j:' + j); 



     });
 });

How can I replace the content of the div above every time this script is invoked?

Essentially, I want to fill up the 3-by-3 div.

So, with the inner loop, I guess I need something like:

$("#type1").$("#image1").html(image here);

What’s the correct way to do this?

i and j gives u, 0,1,2 and 0,1,2.

or is there a better way to do this?

  • 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-07T15:59:27+00:00Added an answer on June 7, 2026 at 3:59 pm

    you can try eq() and start with attribute selector:

    $.each(res, function (i, tickets) {
         $.each(tickets, function (j, ticket) {
             $('div[id^=img]').eq(j).text(ticket)
         });
     });
    

    $.each(res, function (i, tickets) {
         var ind = i;
         $.each(tickets, function (j, ticket) {
             $('#image'+ind+j).text(ticket)
         });
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two dimensional array, i.e. an array of sequences which are also
I have a two-dimensional array. When I print/dump this I get the following My
I have a two dimensional JSON array where each element contains several attributes. The
I have a two dimensional array of points, which constitute a map. The black
I have a output file which is a two dimensional array (this file was
wonder if anyone can help; I have an a two dimensional array which I
I have a two-dimensional array (of Strings) which make up my data table (of
I have a variable called names which is a two dimensional array. I declared
Per PDO's fetchAll() method, I have a two-dimensional array of cities from my database
I have a form in which i use two dimensional array for field names.The

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.