I'm currently working on my homework. I need to delete "ol" from the list using a button with javascript.
I've tried to using a div for all the children and a div for each but doesn't seem to work.
There's my script:
window.onload = function() {
const parent = document.querySelector('ul');
}
function supprime() {
parent.removeChild(parent.lastElementChild);
}
and my html...
<ul>
<ol>Item</ol>
<ol>Item</ol>
<ol>Item</ol>
<ol>Item</ol>
</ul>
<button onclick='supprime()'>DELETE</button>
The console log doesn't show any error.