SHARE
TWEET

Untitled

a guest May 23rd, 2019 63 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.  
  4.   const xlength = allDivs.length
  5.   for (var i = 0; i < xlength; 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);
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