jquery全选反选
来源:互联网 发布:淘宝店开店费用标准 编辑:程序博客网 时间:2024/05/22 05:23
<input type="checkbox" name="id" value="1" /><input type="checkbox" name="id" value="2" /><input type="checkbox" name="id" value="3" /><input type="checkbox" name="id" value="4" /><label><input type="checkbox" id="checkAll" name="checkAll" value="all" />全选</label>
$("#checkAll").on("click",function(){ var checkboxObj = $('input[name="id"]'); console.log(checkboxObj); if($(this).prop("checked")!=false){ checkboxObj.prop("checked",true); }else{ checkboxObj.prop("checked",false); } });