Skip to content

Instantly share code, notes, and snippets.

@themeofn
Created January 8, 2013 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themeofn/4484882 to your computer and use it in GitHub Desktop.
Save themeofn/4484882 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DOM Test</title>
<style>
</style>
<script>
function toggle_dom(){
var d = document, f, i, j, fs, b;
if(this.value === "start"){
f = d.createElement("form");
f.id = "f";
for(i = 0; i < 300; ++i){
fs = d.createElement("fieldset");
for(j = 0; j < 10; ++j){
b = d.createElement("input");
b.type = "button";
b.value = i * 10 + j;
fs.appendChild(b);
}
f.appendChild(fs);
}
d.body.appendChild(f);
this.value = "clear";
}else{
f = d.getElementById("f");
d.body.removeChild(f);
this.value = "start";
}
}
window.onload = function(){
document.getElementById("start").onclick = toggle_dom;
};
</script>
</head>
<body>
<input id="start" type="button" value="start">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment