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

  • Home
  • SEARCH
  • 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 9179437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:47:45+00:00 2026-06-17T17:47:45+00:00

id like to create an array storing: document title document summary document link and

  • 0

id like to create an array storing:

document title
document summary
document link

and then loop through each entry, displaying each in the html.

so far ive got my array..:

var docs = [
{
    doc-title: "onesider number 1",
    doc-info:    "its onesider number 1",
    doc-src: "link here"
},

{
    doc-title: "Onesider number 2",
    doc-info:    "its onesider number 2",
    doc-src: "link here"
}

];

but after this I have no idea how to loop and display each. any suggestions?

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

    You are asking two questions at a time:

    • how to loop in javascript
    • how to append data —from that loop— to the DOM

    You can check this question about loops in javascript, the each() function in jQuery, also take a look at append, prepend, text, html, attr functions in jQuery documentation.

    Here is probably what you are trying to achieve (assuming you are using jQuery) :

    var docs = [
        {
            docTitle: "onesider number 1",
            docInfo:    "its onesider number 1",
            docSrc: "link here"
        },
        {
            docTitle: "Onesider number 2",
            docInfo:    "its onesider number 2",
            docSrc: "link here"
        }
    ],
    
    // This should be your items container  
    container = $('#documents');
    
    
    $.each(docs,function(i,doc){
    
        // Let's create the DOM
        var item = $('<div>').addClass('item'),
            title = $('<h1>'),
            info = $('<p>'),
            link = $('<a>');
    
        // Add content to the DOM
        link.attr('href',doc.docSrc)
        .text(doc.docTitle)
        .appendTo(title);
    
        info.text(doc.docInfo);
    
        // Append the infos to the item
        item.append(title,info);
    
        // Append the item to the container
        item.appendTo(container);
    });
    

    With this base html :

    <div id="documents"></div>
    

    you should end-up with something like :

    <div id="documents">
      <div class="item">
        <h1><a href="link here">onesider number 1</a></h1>
        <p>its onesider number 1</p>
      </div>
      <div class="item">
        <h1><a href="link here">onesider number 2</a></h1>
        <p>its onesider number 2</p>
      </div>
    </div>
    

    Here is the working jsFiddle

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

Sidebar

Related Questions

How do I create an array in smarty from a given string like 22||33||50
So suppose I create an array with 5 spaces, like so - String[] myArray
i would like create a array of structure which have a dynamic array :
I'd like to create an array from a CSV file. This is about as
I would like to create an array of LinearLayout s. In my application I
I would like to create an associative array. I believe I can benefit of
I would like to create a multi-dimensional array with two variables but don't know
I would like to create a json object to send as a post array,
I am trying to create an array which will follow something like this array(
I would like to create a new System.Windows.Xps.Packaging.XpsDocument object from byte array, as I

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.