Permalink
Browse files

Merge pull request #2 from andresmoschini/performant-dom

Change string composition of DOM by array
  • Loading branch information...
martinmeliendrez committed Aug 21, 2012
2 parents a49b2a3 + 2957162 commit d5384106d82fba8bdf2c5cde489dc6a25babee37
Showing with 3 additions and 3 deletions.
  1. +3 −3 InteractingWithDOM/InteractingWithDOM/Scripts/exercises-unit3.js
@@ -11,12 +11,12 @@ function Exercise1() {
function Exercise2() {
// Updates OutputDiv text inside BlueDiv and RedDiv, in a more optimal way
- var html = '';
+ var html = [];
$('div.BlueDiv, div.RedDiv').each(function (index) {
- html += "<br />" + index + $(this).text();
+ html.push("<br />" + index + $(this).text());
});
var outputDiv = $('#OutputDivExercise2');
- outputDiv.html(html)
+ outputDiv.html(html.join(''))
}
// MODIFYING PROPERTIES AND ATTRIBUTES **************************

0 comments on commit d538410

Please sign in to comment.