勾选行变色和全选行变色

//单选行变色
function change(obj){

var tr= $(obj).parent().parent();
if(obj.checked){
tr.addClass("trbgopen");
}else{
tr.removeClass("trbgopen");
}
}
//全选
        queryallinput: function () {
            var inputs = document.getElementById("Payment_list_chekall")
            var tr = $(".Payment_list_chekone").parent().parent();
            if (inputs.checked == true) {
                $(".Payment_list_chekone").prop("checked", true);
                tr.addClass("trbgopen");//行变色
            } else {
                $(".Payment_list_chekone").prop("checked", false);
                tr.removeClass("trbgopen");
            }
        },
th:
<input type="checkbox" id="Payment_list_chekall" style="width:16px;height:16px" v-on:click="queryallinput()" />
tr:
<input type="checkbox" class="Payment_list_chekone" onclick="change(this)"/>

通过点击传入this,再得到父级的父级tr,然后判断当前传入的this.checked是否是选中来添加或移除行变色样式,

全选也是同理,判断所有的checked

猜你喜欢

转载自www.cnblogs.com/liufeiran/p/12614213.html