设置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 tr[data-index='" + index + "']"); //查找某一行的数据

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

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

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

}

});

}

});

相关推荐
weixin_516875652 小时前
力扣 30 天 JavaScript 挑战 第37天 第九题笔记 知识点: 剩余参数,拓展运算符
javascript·笔记·leetcode
明月与玄武2 小时前
Vue 3 高性能实践 全面提速剖析!
前端·javascript·vue.js
童先生6 小时前
Nginx + Vue/React 前端 + API:防止路径混淆漏洞与跨域问题实战分享
前端·vue.js·nginx
黑夜照亮前行的路7 小时前
JavaScript 性能优化实战技术指南
javascript·性能优化
Stringzhua8 小时前
Vue数据的变更操作与表单数据的收集【6】
前端·javascript·vue.js
万少9 小时前
可可图片编辑 HarmonyOS 上架应用分享
前端·harmonyos
你的人类朋友9 小时前
git常见操作整理(持续更新)
前端·git·后端
无羡仙9 小时前
Webpack 核心实战:从零搭建支持热更新与 Babel 转译的现代前端环境
前端·webpack·前端框架
乐~~~9 小时前
el-date-picker type=daterange 日期范围限制
javascript·vue.js·elementui
你的人类朋友9 小时前
git中的Fast-Forward是什么?
前端·git·后端