checkbox 全选或取消

时间:2024-04-19 03:56:13

Html: 点击label 也能 check

<div class="checkbox">
                        <input class="inputCheckbox" id="brandCheck_17" type="checkbox" value="">
                        <label for="brandCheck_17">Lenovo</label>
                    </div>

JQ:

$(".CleanAll").on("click", function ()
        {
            $("input[id^='brandCheck_']").prop("checked", false);

$("a[id^='btnApply_']").attr("style", "display:none;");
           
        });

效果图:checkbox 全选或取消checkbox 全选或取消

其他方法:

$("input[type='checkbox']").attr("checked",false);  只能取消初始已经 checked  的对象,不能全消后来checked.

$(this).prop("checked", false); 可以 实现全选 或 取消