一行jQuery代码搞定checkbox 全选和全不选

来源:互联网 发布:macbook 看图片软件 编辑:程序博客网 时间:2024/05/20 09:06

JavaScript部分:


function checkAll(obj){    $("#box input[type='checkbox']").prop('checked', $(obj).prop('checked'));}

html部分:

<div id="box">    <input type="checkbox" onclick="checkAll(this)">全选<br><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    <input type="checkbox"><br>    </div>
0 0
原创粉丝点击