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

}

});

}

});

相关推荐
zwjapple4 小时前
docker-compose一键部署全栈项目。springboot后端,react前端
前端·spring boot·docker
像风一样自由20206 小时前
HTML与JavaScript:构建动态交互式Web页面的基石
前端·javascript·html
aiprtem7 小时前
基于Flutter的web登录设计
前端·flutter
浪裡遊7 小时前
React Hooks全面解析:从基础到高级的实用指南
开发语言·前端·javascript·react.js·node.js·ecmascript·php
why技术7 小时前
Stack Overflow,轰然倒下!
前端·人工智能·后端
GISer_Jing7 小时前
0704-0706上海,又聚上了
前端·新浪微博
止观止8 小时前
深入探索 pnpm:高效磁盘利用与灵活的包管理解决方案
前端·pnpm·前端工程化·包管理器
whale fall8 小时前
npm install安装的node_modules是什么
前端·npm·node.js
烛阴8 小时前
简单入门Python装饰器
前端·python
袁煦丞9 小时前
数据库设计神器DrawDB:cpolar内网穿透实验室第595个成功挑战
前端·程序员·远程工作