一行jQuery代码搞定checkbox 全选和全不选jquery
JavaScript部分:
function checkAll(obj){
$("#box input[type='checkbox']").prop('checked', $(obj).prop('checked'));
}
html部分:
<div id="box">
<input type=...
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>
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>
最新评论
热门推荐
我要评论