您的位置:首页 > Web前端 > JQuery

全选与取消【jQuery实例】

2017-06-19 15:19 246 查看
//页面部分
<label style="color:#444;">全选:</label><input type="checkbox" onclick="selectall()" id="check_box" title="全选">
//全选jQ部分
function selectall()
{
if($('#check_box').prop('checked'))
{
$(':checkbox').prop('checked', true);
}else{
$(':checkbox').prop('checked', false)
}
}


//第二种方法
function selectAll(){
var obj=document.getElementById('check_box');
if(obj.checked==true){
$('form#group_list_info input[type="checkbox"][name="groupids[]"]').each(function(index,element){
this.checked=true;
})
}else{
$('form#group_list_info  input[type="checkbox"][name="groupids[]"]').each(function(index,element){
this.checked=false;
})
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: