js代码
function selectAllCheckBox(parentid) { var PID = document.getElementById(parentid); var cb = PID.getElementsByTagName("input"); for(var i=0;i<cb.length;i++){ if(cb[i].type == "checkbox"){ cb[i].checked = "checked"; } } }
表单
<div id = "awardall-frame-down"> <button id = "selectallbtn" class="selectallbtn" onclick="selectAllCheckBox(‘awardall-frame-down‘)">全选</button> <input type="checkbox" name="area_id" value="Car">一区</input> <input type="checkbox" name="area_id" value="Car">二区</input> <input type="checkbox" name="area_id" value="Car">三区</input> <input type="checkbox" name="area_id" value="Car">四区</input> <input type="checkbox" name="area_id" value="Car">五区</input> <input type="checkbox" name="area_id" value="Car">六区</input> <input type="checkbox" name="area_id" value="Car">七区</input> <input type="checkbox" name="area_id" value="Car">八区</input> </div>
时间: 2024-10-10 22:30:03