Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<template id="testTemplate">
<div class="test-class1"></div>
<div class="test-class2"></div>
<div class="test-class3"></div>
</template>
</head>
<body>
<div id="parent">
</div>
<script type="text/javascript">
(function() {
var template = document.getElementById('testTemplate'),
clone, i;
function removeNode(node) {
node.parentNode.removeChild(node);
};
for (i = 0; i < 1000; ++i) {
clone = document.importNode(template.content, true);
clone.querySelector('.test-class1').innerHTML = 'Firts Column_' + i;
clone.querySelector('.test-class2').innerHTML = 'Second Column_' + i;
clone.querySelector('.test-class3').innerHTML = 'Third Column_' + i;
document.getElementById('parent').appendChild(clone);
}
let slice = Array.prototype.slice.call;
slice(document.getElementsByClassName('test-class1'), 0).forEach(removeNode);
slice(document.getElementsByClassName('test-class2'), 0).forEach(removeNode);
slice(document.getElementsByClassName('test-class3'), 0).forEach(removeNode);
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment