<%--點擊一行選中一行--%>
<script>
let old, oldColor;
$("#sp_body tr").click(function(i){
if (old)
oldColor = old.css("background-color",oldColor)
old = $(this)
oldColor = old.css("background-color")
$(this).css("background-color","#ddd")
if ($(this).find(".my").prop('checked')) {
$(this).find(".my").prop("checked",false);
}else{
$(this).find(".my").prop("checked", true);
}
});
$("#sp_body tr").dblclick(function(i) {
if (old)
oldColor = old.css("background-color", oldColor)
old = $(this)
oldColor = old.css("background-color")
$(this).css("background-color", "#ddd")
if ($(this).find("#my").prop('checked')) {
$(this).find("#my").prop("checked",false)
}else{
$(this).find("#my").prop("checked", true)
}
});
</script>
如果更換其他的前端框架,可能需要重新渲染。例如LayUI 需要增加
layui.form.render();來對from表單重新渲染