<html>
<head>
</head>
<body>
<div id="11">
<input type="checkbox" name="aa" ><lable>a</lable>
<input type="checkbox" name="aa" /><lable>b</lable>
<input type="checkbox" name="aa" /><lable>c</lable>
<input type="checkbox" name="aa" id="hh"/><lable>d</lable>
</div>
<script>
cast={Method:function test(){
var list=document.getElementsByTagName("input");
for(var i=0;i<list.length;i++)
{
list[i].onclick=function(){
var dv=document.getElementById("11");
dv.removeChild(event.srcElement.nextSibling.nextSibling);
dv.removeChild(event.srcElement)
}
}
}}
cast.Method();
</script>
<input type="button" value="del" />
<input type="button" value="全选"/>
</body>
</html>
网页交互与自动化删除元素
本文介绍了一种通过JavaScript操作HTML元素实现元素自动删除的功能,包括事件监听与DOM操作的基本应用。
2229

被折叠的 条评论
为什么被折叠?



