Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function appendChildren(decorateDivFunction) {
  2. var allDivs = document.getElementsByTagName("div");
  3. var nilai = allDivs.length ;
  4.  
  5. for (var i = 0; i < nilai; i++) {
  6. var newDiv = document.createElement("div");
  7. decorateDivFunction(newDiv);
  8. allDivs[i].appendChild(newDiv);
  9. }
  10. }
  11.  
  12. // Example case.
  13. document.body.innerHTML = `
  14. <div id="a">
  15. <div id="b">
  16. </div>
  17. </div>`;
  18.  
  19. appendChildren(function(div) {});
  20. console.log(document.body.innerHTML)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement