$('table').on('click', 'tr', function (e) {
//选择checkbox判断事件
if (e.target.type === 'checkbox') {
var selectedItems = $("input:checked");
console.log(selectedItems.length)
if(selectedItems.length>1){
$(".table tr").find("input").each(function () {
$(this).removeProp("checked");
});
$(e.target).prop("checked", true);
}
return;
}
//单选行
var input = $(this).find("input");
if ($(input).prop("checked")) {
$(input).removeProp("checked");
} else {
$(".table tr").find("input").each(function () {
$(this).removeProp("checked");
});
$(input).prop("checked", true);
}
});