【求助】这个代码怎么改,才能实现全选啊?
- JScript code
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script><!--function CheckAll(){ var object = event.srcElement; for(var i = 0;i<document.all.length;i++){ if(document.all(i).id.indexOf("checkbox")!=-1){ if(object.checked) document.all(i).checked=true; else document.all(i).checked=false; } }} --></script></head><body> <input type=checkbox name=apple>苹果</input><p> <input type=checkbox name=orange>橘子</input><p> <input type=checkbox name=banana>香蕉</input><p> <input type=checkbox name=grape>葡萄</input><p> <input type=checkbox name=peach>桃子</input><p> <input type=checkbox name=selectAll onclick="CheckAll()">全选</input><p> </body>[解决办法]
if(arr[i].type=="checkbox" && arr[i]!=obj)
input有许多类型,只取其中的checkbox, 并且排除掉全选的那个checkbox