I know how to delete all elements from a list. I don't know how to delete just one item. Let's say I want to delete the 3th list item
<ul id="parent">
<li>
<label>this is the fist item</label>
</li>
<li>
<label>this is the second item</label>
</li>
<li>
<label>this is the third item</label>
</li>
<li>
<label>this is the fourth item</label>
</li>
</ul>
its eassy to delete the fist child or the last child. The list I am building gets built dynamicaly and it will be nice if I can delete the n-th child. It will be nice if I could do something like document.getElementById("someElemet").delete
var ul = document.getElementById('parent');
var liToKill = ul.childNodes[2];
liToKill.parentNode.removeChild( liToKill );
// or ul.removeChild( ... )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With