jquery的一些基本的用法

(1)
//获取所有未选中的input标签
$('input[@type="checkbox"][@checked=""]').each(function(){
   $(this).parent('td').parent('tr');//获取checkbox未被选中的该行
   alert($(this).parent('td').parent('tr').innerHTML);//验证
}); 


(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']表示不是全选框)的点击事件发生时,方法里面的内容被执行。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值