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

The Archive Base Latest Questions

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

I create a div and its css id like this. <div id=r1 class=ansbox></div> <div

  • 0

I create a div and its css id like this.

<div id="r1" class="ansbox"></div>
<div id="r2" class="ansbox"></div>
<div id="r3" class="ansbox"></div>
<div id="r4" class="ansbox"></div>
<div id="r5" class="ansbox"></div>
<div id="r6" class="ansbox"></div>
<div id="r7" class="ansbox"></div>
<div id="r8" class="ansbox"></div>
<div id="r9" class="ansbox"></div>
<div id="r10" class="ansbox"></div>

is there a way to create this div using looping statement. Anyone help me..

  • 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:08:48+00:00Added an answer on June 7, 2026 at 3:08 pm

    I would recommend using some javascript (without jquery) for performance:

    var toAdd = document.createDocumentFragment();
    for(var i=0; i < 11; i++){
       var newDiv = document.createElement('div');
       newDiv.id = 'r'+i;
       newDiv.className = 'ansbox';
       toAdd.appendChild(newDiv);
    }
    
    document.appendChild(toAdd);
    

    This way you only make one append(), only 1 reflow, and you don’t need jQuery.

    To append it to a jQuery selector:

    $('sel').append(toAdd);
    

    Or a dom element:

    document.getElementById('sel').appendChild(toAdd);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm gonna create two div tags with CSS that appear in the page like
Is there any way to create a css box-shadow in which regardless of the
I'm using the HTML/CSS/JavaScript/jQuery to create a UI palette for a Sketchup plug-in. There
I have a template like this: <script id=notesTemplate type=text/html> <li class=Note> <div class=NoteDate data-bind=style:
I'd like to create an infinite side scrolling div without using extra plugins (besides
I am using a javascript form validator, and it creates a div for its
Possible Duplicate: JavaScript library to create div-style window within page I would like to
I create Any div in auto width with single image background. in act this
I have this html: <div class="object-box"> <img ... /> <span class="caption">This is the caption</span>
I would like to create a gallery slideshow using Jquery Tools Scrollable plugin. But

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.