首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

这个代码如何改,才能实现全选啊

2012-02-28 
【求助】这个代码怎么改,才能实现全选啊?JScript codehtmlheadmeta http-equivContent-Type content

【求助】这个代码怎么改,才能实现全选啊?

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

热点排行