Created
May 12, 2019 06:33
-
-
Save derryberni/0dc4257a595746739e3f281c30e834f7 to your computer and use it in GitHub Desktop.
This file contains 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
function appendChildren(decorateDivFunction) { | |
var allDivs = document.querySelectorAll("div"); | |
for (var i = 0; i < allDivs.length; 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