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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:11:32+00:00 2026-06-14T17:11:32+00:00

In my js I get a list ‘data’ that looks like that: data =

  • 0

In my js I get a list ‘data’ that looks like that:

data = {test: 'test', test2:'test2', test3 : buffer}

My ‘buffer’ has this form:

buffer =[{testa: 'testa', testb : 'testb'}, {testc: 'testc', testd : 'testd'}, {teste: 'teste', testf : 'testf'} ... ]

What I would like to do is for each element of the buffer, use the data it contains an do an append like this.

$('.try').append('<div> <p> '+testa+' </p> <p> '+testb+' </p> <div>')
$('.try').append('<div> <p> '+testc+' </p> <p> '+testd+' </p>)
...

html:

<div class='try' >

Any idea on how to do that?

I know I can access ‘buffer’ with ‘data.buffer’. But then, I need to create a loop with each element of ‘buffer’ and then for each element of buffer, extract the data in it and create a new div…

Any help would be very welcome.

EDIT:
Here is what I tried:

    for (var i in data.buffer) $('.try').append('<div> <p> '+i.testa' </p> <p> '+i.testb' </p> </div>')

But it doesn’t work.

  • 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-14T17:11:34+00:00Added an answer on June 14, 2026 at 5:11 pm

    Use $.each to iterate over your Object..

    Try this

    var buffer=[{testa: 'testa', testb : 'testb'}, 
                {testc: 'testc', testd : 'testd'}, 
                {teste: 'teste', testf : 'testf'}]​;
    
    var html = '';
    $.each(buffer ,function(i, v){ // Iterate over the Array
        html += '<div>' ;
        $.each(v, function(j,value) { // Iterate over each object
            html += '<p> '+ value+' </p>' ;
        });   
        html += '</div>' ;        
    });
    
    
    $('.try').append(html);
    

    Check Fiddle

    ​
    UPDATE

    For the second format you are asking .. Remove the innermost $.each

    var html = '';
    $.each(buffer, function(i, v) { // Iterate over the Array
        html += '<div>';
        var k = 0;
        $.each(v, function(j, value) { // Iterate over each object
            if (k == 0) {
                html += '<p> ' + value + ' </p>';
            }
            else {
                html += '<img src="' + value +'" />';
            }
            k++;
        });
        html += '</div>';
    });
    
    $('.try').append(html);​
    

    Fiddle

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

Sidebar

Related Questions

I have this query that get list of records and traces the genealogy of
Can't get list sorted by date. How to show data ordered by date? XDocument
How to get list of files that a program is working with? For example,
How can I get List() from this text: For the iPhone do the following:<ul><li>Go
Possible Duplicate: Get list of all input objects using JavaScript, without accessing a form
I am trying to get list of all defined namespaces by XmlNamespaceManager in this
This is a similar question to How can i get list of Domain user's
On my application starting I need to get list of libraries that are linked
I'm using readlines method from python to get list of all data lines. Now
I get List<Strings> by executing a query. This must be passed to another query

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.