deleting an element 2 parents back

T

teranetsecurity

so suppose I have a list (ul) and In this list I have some (li's)... I
want to be able to delete the li's from a link in the div..

so somthing that would theoretically look like this

<ul>
<li id="one>
<a href="#"
onclick="this.parentNode.parentNode.removechild(li);">check</a>//this
doesnt work
<li id="two">
<li id="three>
</ul>

I want remove the li's dynamically using somthing that is like the
method I have above but I am unable to get it to work. I can get it to
display the id of the li via this.parentNode.parentNode.id but I am
unable to actually remove it from the DOM. Any ideas. thanks
 
A

ASM

(e-mail address removed) a écrit :
so suppose I have a list (ul) and In this list I have some (li's)... I
want to be able to delete the li's from a link in the div..

<ul>
<li id="one>
<a href="#"
onclick="this.parentNode.parentNode.removechild(li);">check</a>//this

it is : removeChild()
and what could be 'li' in your code (nothing known ...)

onclick="this.parentNode.parentNode.removeChild(this.parentNode);">check</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top