Created
October 3, 2021 11:42
-
-
Save TheRolfFR/a15291208e3138d6c1f64aec2b5736d7 to your computer and use it in GitHub Desktop.
Removes all elements from a NodeList. This NodeList is generally a document element query result.
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
/** | |
* Removes all elements from a NodeList. | |
* This NodeList is generally a document element query result. | |
* @author TheRolf | |
*/ | |
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { | |
for(var i = this.length - 1; i >= 0; i--) { | |
if(this[i] && this[i].parentElement) { | |
this[i].parentElement.removeChild(this[i]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment