bootstrap icheck插件

本文介绍如何使用jQuery插件iCheck来实现单选按钮的状态切换,包括取消选择已选中的选项及从未选中状态变为选中状态。此外还展示了如何通过监听全选按钮来实现表格中所有复选框的全选或全不选操作。

//判断单选是否有是选中的,如果选中点击就不选中,如果不选中,点击就选中

$("input[type='radio']").on('ifClicked', function (event) {
   if ($(this).attr("checked",true)) {
     $(this).iCheck('uncheck');
   } else {
     $(this).iCheck('check');
   }
});

或者

$(".ifcheck_radio input[type='radio']").on('ifClicked', function (event) {
if($(this).closest(".iradio_square-blue").attr("class").indexOf("checked")>-1){
$(this).closest(".iradio_square-blue").removeClass("checked");
}else{
$(this).closest(".iradio_square-blue").addClass("checked");
}
});

//表单的全选/全不选

$('.list-content table tr:first-child th:first-child input').on('ifChecked ifUnchecked', function(event) {
if (event.type == 'ifChecked') {
$(".list-content table tr td input").iCheck('check');
} else {
$(".list-content table tr td input").iCheck('uncheck');
}
})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值