设置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"); //标记该行某一列的颜色

}

});

}

});

相关推荐
dog shit11 分钟前
web第十次课后作业--Mybatis的增删改查
android·前端·mybatis
我有一只臭臭11 分钟前
el-tabs 切换时数据不更新的问题
前端·vue.js
七灵微15 分钟前
【前端】工具链一本通
前端
Nueuis1 小时前
微信小程序前端面经
前端·微信小程序·小程序
_r0bin_4 小时前
前端面试准备-7
开发语言·前端·javascript·fetch·跨域·class
IT瘾君4 小时前
JavaWeb:前端工程化-Vue
前端·javascript·vue.js
zhang98800004 小时前
JavaScript 核心原理深度解析-不停留于表面的VUE等的使用!
开发语言·javascript·vue.js
potender4 小时前
前端框架Vue
前端·vue.js·前端框架
站在风口的猪11084 小时前
《前端面试题:CSS预处理器(Sass、Less等)》
前端·css·html·less·css3·sass·html5
程序员的世界你不懂5 小时前
(9)-Fiddler抓包-Fiddler如何设置捕获Https会话
前端·https·fiddler