layui设置表格表头字体_layui表格更改某列的背景颜色或者字体颜色

layui表格更改某列的背景颜色或者字体颜色

 0

 2877

TSIM

2019/6/26 15:29:11

区分某个字段不同的情况下,显示成的某列的表格颜色不同

做法为在layui表格下layui.use('table', function () 函数里增加done函数

具体代码如下:

[pre]

layui.use('table', function () {

var table = layui.table;

table.init('test', {

toolbar: '#toolbarDemo'

,defaultToolbar: ['filter', 'print', 'exports']

, done: function (res, curr, count) {

console.log(index)

for (var i = 0; i < index; i++) {

$("[data-field='kc" + i + "']").children().each(function () {

if ($(this).text() == '未完成') {

$(this).css({ "background-color": "#ff0000", "color": "#ffffff" });

} else if ($(this).text() == '学习中') {

$(this).css({ "background-color": "#ada548", "color": "#ffffff" });

} else if ($(this).text() == '未参加') {

$(this).css({ "background-color": "#808080", "color": "#ffffff" });

} else if ($(this).text()>0) {

$(this).css({ "background-color": "#439a7a", "color": "#ffffff" });

}

});

}

console.log(JSON.stringify(res))

}

});

})

[/pre]

效果如下:

img[/layedit/img/201906261527486230.png]

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值