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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:10:05+00:00 2026-06-09T19:10:05+00:00

How do I append elements into the dom in one go? As you can

  • 0

How do I append elements into the dom in one go? As you can see from the code below I’m appending stuff into a root element(tr_next) inside a loop.

$('.abc').each(function(){
  //create element code here
  var tr_next = $("<tr>");
  var td_contact_fname = $("<td>").attr({"width" : "190px" , "align" : "center"});

  td_contact_fname.appendTo(tr_next);
  td_contact_lname.appendTo(tr_next);
  td_month.appendTo(tr_next);
  td_day.appendTo(tr_next);
  td_email.appendTo(tr_next);
});

I’ve watched this video at vimeo: How browsers work internally and they said that when appending stuff into the dom you should do it in one go because the browser needs to perform a lot of repainting(or something like that) which affects performance.

  • 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-09T19:10:07+00:00Added an answer on June 9, 2026 at 7:10 pm

    jQuery Fundamentals has some handy guidelines about this.

    Loops like your sample and what ends up happening with ‘append(item1,item2)’ are the slowest.

    You might want to create a document fragment, append everything to that and then after the loop is complete, append the fragment to the body:

       var frag = document.createDocumentFragment();
       $('abc').each(function() {
          frag.appendChild(/*Stuff you want to append */);
       }
       $("<tr>").appendChild(frag);
    

    Or use the loop to build a string of html and append like so

     $('<tr>').html(myHtmlString)    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I'm using the following code to append certain elements to the DOM: $('<p/>',
All. I am using jquery. And I want to append element into loaded html
.append Function adds elements to the list. How can I add elements to the
I'm trying to append a string of svg elements to the dom. This is
After adding elements to page using something like this, $('#blah').append('<div id=bugsbunny></div>'); how can I
Is it possible to access $_POST variables without appending all the form elements into
I want to add a element into the existing DOM to have the javascript
i am not able to remove elements from the dom. i am using firfox.
I am using the following code to append some ul and li elements directly
Possible Duplicate: Python : how to append new elements in a list of list?

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.