JS点击一个元素删除其父元素

< html >
< head >
     < meta  charset = "utf-8" >
     < title >e演示 title >
     < script  type = "text/javascript" >
     function deleteElement(Obj){
         Obj.parentNode.parentNode.removeChild(Obj.parentNode);
     }
     script >
head >
< body >
      < ul  class = "list2"  >
< li  >
< img  alt = ""  src = "1.jpg"  />
< div >mingzi1 div >
< a  onclick = "deleteElement(this)" >删除 a >
li >
< li  >
< img  alt = ""  src = "2.jpg"  />
< div >mingzi2 div >
< a  onclick = "deleteElement(this)" >删除 a >
li >
< li  >
< img  alt = ""  src = "3.jpg"  />
< div >mingzi3 div >
< a  onclick = "deleteElement(this)" >删除 a >
li >
ul >
body >
html >

你可能感兴趣的:(JavaScript)