"columnDefs":[
{
"targets":7,
createdCell:function(td,cellData,rowData,row,col){
if(cellData =='Slight'){
$(td).addClass("glyphicon glyphicon-wrench").css('color','rgb(255, 255, 0)').text('');
}else if(cellData == 'Minor'){
$(td).addClass("glyphicon glyphicon-wrench").css('color','rgb(255, 135, 0)').text('');
}else if(cellData == 'Major'){
$(td).addClass("glyphicon glyphicon-wrench").css('color','rgb(255, 0, 0)').text('');
}
}
},
]
效果由

变成:

这段代码展示了如何使用CSS和jQuery根据不同的数据类别(Slight, Minor, Major)为表格单元格添加不同颜色和图标的样式。通过为每个级别分配特定的颜色和图标,实现了视觉上的分类提示。
1636

被折叠的 条评论
为什么被折叠?



