Skip to content

Instantly share code, notes, and snippets.

@dhanyn10
Created January 18, 2019 10:09
Show Gist options
  • Save dhanyn10/78366f334b8d764d4daaa5bd415fe046 to your computer and use it in GitHub Desktop.
Save dhanyn10/78366f334b8d764d4daaa5bd415fe046 to your computer and use it in GitHub Desktop.
melalui test code browser sudah saya test berkali
function appendChildren(decorateDivFunction) {
var allDivs = document.getElementsByTagName("div");
divlength = allDivs.length;
for (var i = 0; i < divlength; i++) {
var newDiv = document.createElement("div");
decorateDivFunction(newDiv);
allDivs[i].appendChild(newDiv);
}
}
// Example case.
document.body.innerHTML = `
<div id="a">
<div id="b">
</div>
</div>`;
appendChildren(function(div) {});
console.log(document.body.innerHTML);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment