removeChild on a li inside a ul inside a div with an id?
- by Prozaker
I have the following code on a webpage:
<div id="emails">
<ul>
<li>email1</li>
<li>email2</li>
</ul>
</div>
<a href="#" onClick="javascript:deleteEmail">click</a>
and I want to remove the first email, i've been trying with this:
function deleteEmail(){
var ul = document.getElementById('alt_emails').getElementsByTagName('ul');
ul.removeChild(ul.childNodes[0]);
}
im kinda new to Javascript DOM, so if there's a better way to do it, please let me know.
Note: I would like to do this without any kind of js framework.