Created
November 11, 2011 22:06
-
-
Save jrmoran/1359466 to your computer and use it in GitHub Desktop.
adding radios elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This takes ~35ms | |
console.time('Virguilla radios'); | |
for(var x=0; x<500; x++){ | |
var radios=document.createElement("input"); | |
radios.type = "radio"; | |
radios.id = "nombreRadio"; // NOOOOOOOOOOO! | |
radios.name = "nombreRadio"; | |
radios.value = x; | |
document.getElementById("test-form").appendChild(radios); // NOOOO! | |
} | |
console.timeEnd('Virguilla radios'); | |
// ~ 17ms | |
console.time('radios'); | |
// Just create a radio element | |
var radio = document.createElement('input'); | |
radio.type = 'radio'; | |
radio.name = 'nombreRadio'; | |
var tempd = document.createElement("div"); | |
for(var x = 0; x < 500; x++){ | |
var nr = radio.cloneNode(false); | |
nr.value = x; | |
tempd.appendChild(nr); | |
} | |
document.getElementById('test-form').appendChild(tempd); | |
console.timeEnd('radios'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment