對部分標籤新增onclick事件
阿新 • • 發佈:2019-02-13
<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>