Created
January 16, 2024 08:05
-
-
Save johnroyer/9bb2cee01f5f17090da18bbc80b61355 to your computer and use it in GitHub Desktop.
JavaScritp for() break after node removed
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
<html> | |
<body> | |
<ul id="target"> | |
<li>1111</li> | |
<li>2222</li> | |
<li>3333</li> | |
<li>4444</li> | |
<li>5555</li> | |
</ul> | |
<script> | |
let nodes = document.getElementById('target').children | |
for(let index in nodes) { | |
console.log(nodes[index]) | |
nodes[index].remove() | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment