<html>
<body>
<ol id = "elem>
<li>hello</li>
<li>world</li>
</ol>
<script>
function clear(elem) {
for(let i = o; i < elem.childNodes.length; i++){
elem.childNodes[i].remove();
}
}
</script>
</body>
</html>
/*
//other way
function clear(elem){
while (elem.firstChild){
elem.firstChild.remove();
}
}
THE COOLEST WAY
function clear(elem){
elem.innerHTML = '';
}
this is a task about how to remove element.
the last one is definitely so cool.
no one said the element ol should be in the place
we could just blow all up lol
*/
<body>
<ol id = "elem>
<li>hello</li>
<li>world</li>
</ol>
<script>
function clear(elem) {
for(let i = o; i < elem.childNodes.length; i++){
elem.childNodes[i].remove();
}
}
</script>
</body>
</html>
/*
//other way
function clear(elem){
while (elem.firstChild){
elem.firstChild.remove();
}
}
THE COOLEST WAY
function clear(elem){
elem.innerHTML = '';
}
this is a task about how to remove element.
the last one is definitely so cool.
no one said the element ol should be in the place
we could just blow all up lol
*/
댓글
댓글 쓰기