daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function appendChildren(decorateDivFunction) {
  2.   var allDivs = document.getElementsByTagName("div");
  3.   var lenght = allDivs.length;
  4.   for (var i = 0; i < lenght; i++) {
  5.     var newDiv = document.createElement("div");
  6.     decorateDivFunction(newDiv);
  7.     allDivs[i].appendChild(newDiv);
  8.   }
  9. }
  10.  
  11. function decorateDivFunction(div) {}
  12.  
  13. // Example case.
  14. document.body.innerHTML = `
  15. <div id="a">
  16.   <div id="b">
  17.   </div>
  18. </div>`;
  19.  
  20. appendChildren(function(div) {});
  21. console.log(document.body.innerHTML);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top