87,907
社区成员
发帖
与我相关
我的任务
分享
$('.chebox').each(function(){
$(this).click(function(){
if($(this).prop('checked')){
//$('.chebox').prop('checked',true);
$(":checkbox").each(function(){
if(!$(this).is(':disabled')){
$(this).prop('checked',true);
}
})
}else{
$(":checkbox").each(function(){
$(this).prop('checked',false);
})
}
// if(!box.is(':disabled')){
// alert(1);
// box.prop('checked',true);
// }
})
})
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-beta1.js"></script>
</head>
<body>
<input type="checkbox" class="chebox" /><input type="checkbox" class="chebox" disabled /><input type="checkbox" class="chebox" /><input type="checkbox" class="chebox" /><input type="checkbox" class="chebox" /><input type="checkbox" class="chebox" />
<script type="text/javascript">
$(function(){
//console.log($(".check"))
$(".chebox").each(function(){
if(!$(this).is(':disabled')){
$(this).prop('checked',true);
}
})
})
</script>
</body>
</html>