<input type="checkbox" value="" id="checkall" name="" size="" class="m-wrap " onclick="checkfk()"> <span class="">(全选)</span> <input type="checkbox" name="fkcheck" value="" id="" size="" class="m-wrap " > <span class="">现付</span> <input type="checkbox" name="fkcheck" value="" id="" size="" class="m-wrap " > <span class="">到付</span> <input type="checkbox" name="fkcheck" value="" id="" size="" class="m-wrap " > <span class="">月付</span> <input type="checkbox" name="fkcheck" value="" id="" size="" class="m-wrap " > <span class="">回执付</span> <input type="checkbox" name="fkcheck" value="" id="" size="" class="m-wrap " > <span class="">返厂付</span>
function checkfk(){ var allcheck=document.getElementById("checkall"); //获取 全选check 的id var othercheck=document.getElementsByName("fkcheck"); //获取数组名称为fkcheck的 复选框
for(var i=0;i<othercheck.length;i++){ if(allcheck.checked){ othercheck[i].checked=true; }else{ othercheck[i].checked=false; } } } //循环遍历 复选框 ,当点击全选时,其它被选中,否则取消选中