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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:24:50+00:00 2026-06-14T15:24:50+00:00

I have the following HTML that I want to repeat 5 times within a

  • 0

I have the following HTML that I want to repeat 5 times within a div container (.container).

<div class="block">
   <div class="name">Name</div>
   <div class="content>Content</div>
</div>

Using jQuery/JS, I want to create an array (or some other kind of organization structure), that when run through a for loop could CHANGE the ‘Name’ and ‘Content’ of each block.

For example, I have two arrays:

var names = ["Joe","Jane","Bill","Nicole","Dennis"];
var content = ["First content","Second content","Third content","Fourth content","Fifth content"]

I want to clone the top HTML and for each block, change the name and content to its respective array item. How can I do this?

Right now, I have the code to just repeat the HTML.

var row = $('.block');

for(var i = 0; i < 5; i++ )
  $('.container').append(row.clone())
}

Edit: Is there a better way to do this without creating multiple arrays?

  • 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-14T15:24:51+00:00Added an answer on June 14, 2026 at 3:24 pm

    You can use find and text methods and change the content of elements before appending them, note that you are missing opening { for the for block.

    for (var i = 0; i < 5; i++) {
       row.clone()
          .find('.name').text(names[i]).end()
          .find('.content').text(content[i]).end()
          .appendTo('.container')
    }
    

    http://jsfiddle.net/SU3vF/

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

Sidebar

Related Questions

I have the following HTML that I want to repeat 5 times within a
So I have some html that looks like the following: <div class='something unknown' id='something_unknown_1'>
I have the following code: <a href=main.html class=admin><div class=buttonlabel>Admin</div></a> and CSS a.admin { display:block;
I have the following html that I am trying to modify: <div class=col1 width8><img
i have the following problem with that code in my html tag: <div id=searchbar><input
I have a single .html file that looks similar to the following: <div id=myPage
I have the following index.html page set-up: <html> <head> </head> <body> <div id=container> <div
I have the following html page: <body> <div class=hide1 style=width:1000px; height:1000px;> <table width=100% border=0
I have following html site structure: <body> <div id=header></div> <div id=container> <div id=util_header></div> <div
I have the following code: HTML <ul id=navigation> <li class=quickHelp><a href= title=Ayuda Rápida></a> <div>

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.