Guest User

Untitled

a guest
Jul 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. Element.prototype.removeChildren = () => {
  2. while(this.firstChild) {
  3. this.removeChild(this.firstChild);
  4. }
  5. }
  6.  
  7. // the main problem of this script is not working prototype method 'removeChildren';
  8. // but all without a method works perfectly!
  9.  
  10.  
  11. var footer = document.querySelector('#footer');
  12.  
  13. footer.removeChildren();
  14.  
  15. // it doesn't work unfortunately!
  16.  
  17. for (var i = 0; i < footer.childElementCount; i++) {
  18. footer.removeChild(footer.firstChild);
  19. }
  20.  
  21. // it works without problems!
Add Comment
Please, Sign In to add comment