-----------------------------html-----------------------------------------
<input type="checkbox" name="test"/>1<input type="checkbox" name="test"/>2<input type="checkbox" name="test" />3<input type="checkbox" name="test" />4<input type="checkbox" name="test" />5<input type="checkbox" id="chooseall" onclick="selectAll()"/>全选 -------------------------js-----------------------------------
var chooseall=document.getElementById("chooseall"), mytest=document.getElementsByName("test"), leng=mytest.length;function selectAll(){ if(chooseall.checked==true){ for(i=0;i<leng;i++){ mytest[i].checked=true; } }else{ for(i=0;i<leng;i++){ mytest[i].checked=false; } }}
时间: 2024-10-31 11:13:17