Created
January 4, 2019 16:07
-
-
Save azulkipli/a829781b2653fffb86c2ebb7cdc695d3 to your computer and use it in GitHub Desktop.
JDS_Javascript
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(decorateDiv) { | |
var allDivs = document.getElementsByTagName("div"); | |
var numberOfDivs=allDivs.length; | |
for (var i = 0; i < numberOfDivs; i++) { | |
var newDiv = document.createElement("div"); | |
decorateDiv(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