(2)
<div id="divId" class="divTable"> <div class="tableBody"> <ul ><li ><input type="checkbox" value="501" ></li></ul> </div> </div> js:
$("input[type='checkbox']").attr('value') 返回结果:501 $("input[type='checkbox']").is(':checked') 返回结果:选中=true,未选中=false(3):
$("input[type=checkbox][name=11111][checked]").length 将11111改为你的checkbox的name属性,上面的值就是选中个数
(4):
html:
<tbody><tr>
<td><input type="checkbox" class="check1" value="allselect" name="" id="allselect">全选</td>
<td><input type="checkbox" class="check1" value="1" name="" >1</td>
<td><input type="checkbox" class="check1" value="2" name="" >2</td>
<td><input type="checkbox" class="check1" value="3" name="" >3</td>
<td><input type="checkbox" class="check1" value="4" name="" >4</td>
</tr>
</tbody>
$("input[type=checkbox][value!='allselect']").click(function(){
//给全选按钮做绑定(当下面的用户全选时按钮也跟着选中,反之则让其不选中)
$("#allselect").attr("checked",$("input[type=checkbox][value!='allselect']").length == $("input[type=checkbox][value!='allselect']:checked").length ? true:false);
if($(this).attr("checked")){
//alert($(this).attr("checked"));
$(this).attr("checked",true);
}
else{
$(this).attr("checked",false);
}
});
意思是:当多选框([value!='allselect']表示不是全选框)的点击事件发生时,方法里面的内容被执行。