设置layui动态表格某一行的背景色

以下示例设置动态表格某一行的数据

ea.table.render({

init: init,

toolbar: 'refresh', 'delete','add',

cols: [[

{type: 'checkbox'},

{field: 'id', title: 'id'},

{field: 'cate.title', title: '分类'},

{field: 'image', title: '缩略图', templet: ea.table.image},

{field: 'name', title: '姓名'},

{field: 'phone', title: '电话'},

{field: 'license_number', title: '执业证号'},

{field: 'level', title: '等级'},

{field: 'province', title: '省'},

{field: 'city', title: '市'},

{field: 'good_sector', title: '擅长领域'},

{field: 'remark', title: '备注', templet: ea.table.text},

{field: 'create_time', title: '添加时间'},

{field: 'status', title: '状态', templet: ea.table.switch},

{field: 'price', title: '价格'},

{width: 250, title: '操作', templet: ea.table.tool},

]],

done: function (res, curr, count) {

console.log(res); //打印数据

console.log(curr);//打印当前行数

console.log(count); //数据总条数

// 官方介绍 https://www.layui.com/doc/modules/table.html#templet

res.data.forEach(function (item, index) { //循环数据

if (item.id == 1) { //当数据id为1时

var tr = $(".layui-table").find("tbody trdata-index='" + index + "'"); //查找某一行的数据

tr.css("background-color", "#98FB98"); //标记该行的背景色

// 给1-0-9列添加样式

tr.find(".laytable-cell-1-0-9").css("color","red"); //标记该行某一列的颜色

}

});

}

});

相关推荐
扶风ff4 小时前
新品知识更新太快?用练题簿在线刷题,安排企业培训的小测与复盘
前端·学习·小程序
对空六课4 小时前
支持注意力分析的热力图工具有哪些?
前端·数据库·数据分析
Csvn5 小时前
Vue3 响应式与编译:依赖收集如何升级为节点级靶向更新
前端
星栈6 小时前
pnpm 12 升级实测
前端·javascript
Sirens.7 小时前
Java并发锁详解:六类锁策略与 synchronized 底层原理
java·前端·算法
Ai-_Man7 小时前
您您这可以把Microsofat Copilot的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。AI导出鸭
javascript·人工智能·ai·小程序·电脑·copilot
特创数字科技8 小时前
一个纯本地运行的图片处理工具:压缩 / 裁剪 / 九宫格 / 圆角 / 滤镜 / 拼图 / 水印,终生使用
前端
IT_陈寒9 小时前
Vue的v-if和v-for混用居然是个天坑
前端·人工智能·后端
天衍四九-9 小时前
【无标题】
前端·spring boot·mysql·nginx·docker
广州华水科技9 小时前
2026年单北斗GNSS变形监测系统推荐榜单,解锁GNSS位移监测新高度
前端