$(document).on("click",".layui-table-body table.layui-table tbody tr",function(){
var obj = event ? event.target : event.srcElement;
var tag = obj.tagName;
var checkbox = $(this).find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
var dataIndex = $(this).attr("data-index");
if($(this).parents(".layui-table-fixed").length>0){
if(checkbox.length!=0){
if(tag == 'DIV') {
checkbox.click();
}
}
}else{
var checkbox1=$(this).parents(".layui-table-body").next().find(".layui-table-body table.layui-table tbody tr[data-index="+dataIndex+"]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");;
if(checkbox1.length!=0){
if(tag == 'DIV') {
checkbox1.click();
}
}
}
//让其高亮显示 需要自己设置颜色.tr_selected{background: #888 !important;}
var boxtr=$(this).parents(".layui-table-box").find("tr[data-index="+dataIndex+"]");
$(boxtr).each(function(){
if(!$(this).hasClass("tr_selected")){
$(this).addClass("tr_selected").siblings().removeClass("tr_selected");
}
})

});

$(document).on("click","td div.laytable-cell-checkbox div.layui-form-checkbox",function(e){
e.stopPropagation();
});
posted on 2018-10-22 11:19  努力才会进步  阅读(740)  评论(0编辑  收藏  举报