jQuery data table parent node to find and set style

1. Effect picture:

Insert picture description here

2. Analysis

Requirements :

The report status will be marked as red

jsp style code:

Insert picture description here
analysis:

I just need to start with the <span tag and end with the <tr tag

Level:

<table>
	<tr>
		<td>
			<div>
				<span>

3. Code:


{
    
    field: 'reportstatus',
	                    title: '审核状态',
	                    width: 100,
	                    align: 'left',
	                    halign: 'center',
	                    sort: true, filter: true,
	                    templet: function (row) {
    
    
	                        if (row.reportstatus == "0") {
    
    
	                            return  '<span style="color: #409EFF;">待审核</span>'
	                        } else if (row.reportstatus == "1") {
    
    
	                            return  '<span style="color: #3CB371;">审核完成</span>'
	                        } else if (row.reportstatus == "2") {
    
    
	                            return  '<span class="dl_authfail">审核失败</span>'
	                        } else if (row.reportstatus == "3") {
    
    
	                            return  '<span style="color: #00CED1;">上报完成</span>'
	                        } else if (row.reportstatus == "4") {
    
    
	                            return  '<span style="color: #808080;">临时保存</span>'
	                        }
	                    }
	                },
    done: function (res, curr, count) {
    
    
    layui.soulTable.render(this)
    $(".dl_authfail").parent().parent().parent().css("background","#f40c0775");
 }


note:

1. In the data table, set a class style class="dl_authfail"
2. When done rendering the data table, add the set style
$(".dl_authfail").parent().parent().parent ().css("background","#f40c0775");

4. Knowledge summary:

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_36636312/article/details/110822496