Skip to content

Instantly share code, notes, and snippets.

@yuheiy
Created October 3, 2015 13:08
Show Gist options
  • Save yuheiy/c194e3838c3ca4386292 to your computer and use it in GitHub Desktop.
Save yuheiy/c194e3838c3ca4386292 to your computer and use it in GitHub Desktop.
var frag = document.createDocumentFragment();
for (var i = 0, l = users.length; i < l; i++) {
var user = users[i];
var dl = document.createElement('dl');
var nameTerm = document.createElement('dt');
nameTerm.textContent = 'name';
dl.appendChild(nameTerm);
var nameDesc = document.createElement('dd');
nameDesc.textContent = user.name;
dl.appendChild(nameDesc);
var ageTerm = document.createElement('dt');
ageTerm.textContent = 'age';
dl.appendChild(ageTerm);
var ageDesc = document.createElement('dd');
ageDesc.textContent = user.age;
dl.appendChild(ageDesc);
frag.appendChild(dl);
}
var result = document.getElementById('result');
result.appendChild(frag);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment