Created
January 18, 2019 14:50
-
-
Save rozium/5190bb0d0b7c43b973213bc005777364 to your computer and use it in GitHub Desktop.
Jabar Digital Service - Frontend - 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(decorateDivFunction) { | |
var allDivs = document.getElementsByTagName("div"); | |
var len = allDivs.length; | |
for (var i = 0; i < len; i++) { | |
var newDiv = document.createElement("div"); | |
decorateDivFunction(newDiv); | |
allDivs[i].appendChild(newDiv); | |
} | |
} | |
function decorateDivFunction(div) {} | |
// Example case. | |
document.body.innerHTML = ` | |
<div id="a"> | |
<div id="b"> | |
</div> | |
</div>`; | |
appendChildren(decorateDivFunction); | |
console.log(document.body.innerHTML); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment