Jquery:遍历一个表以查找某个值的出现情况并更改行';s css
我的表格结构如下:Jquery:遍历一个表以查找某个值的出现情况并更改行';s css,jquery,html,css,Jquery,Html,Css,我的表格结构如下: <table id="table1"> <thead> <tr> <th>Task</th> <th>Status</th> </tr> </thead>
<table id="table1">
<thead>
<tr>
<th>Task</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>task 1</td>
<td>SUC</td>
</tr>
<tr>
<td>task 2</td>
<td>SUC</td>
</tr>
<tr>
<td>task 3</td>
<td>ERR</td>
</tr>
<tr>
<td>task 4</td>
<td>ERR</td>
</tr>
它只是改变了columun状态的特定单元格的css
我想更改整行的css,状态为ERR。
我试过类似的方法
$(this).parent().css('background-color', '#59f763');
试试这个:使用
closest('tr')
试试这个:使用
closest('tr')
试试这个:使用
closest('tr')
试试这个:使用
closest('tr')
在jquery中使用
$("#table1 td:contains('ERR')").parent().css('background-color', '#59f763');
在jquery中使用
$("#table1 td:contains('ERR')").parent().css('background-color', '#59f763');
在jquery中使用
$("#table1 td:contains('ERR')").parent().css('background-color', '#59f763');
在jquery中使用
$("#table1 td:contains('ERR')").parent().css('background-color', '#59f763');
尝试更改此选项:
$(this).parent().css('background-color', '#59f763');
为此:
$(this).closest('tr').find('td').css('background-color', '#59f763');
尝试更改此选项:
$(this).parent().css('background-color', '#59f763');
为此:
$(this).closest('tr').find('td').css('background-color', '#59f763');
尝试更改此选项:
$(this).parent().css('background-color', '#59f763');
为此:
$(this).closest('tr').find('td').css('background-color', '#59f763');
尝试更改此选项:
$(this).parent().css('background-color', '#59f763');
为此:
$(this).closest('tr').find('td').css('background-color', '#59f763');
您可以使用以html“ERR”过滤td,然后使用parent()获取其父tr并对其应用css
您可以使用以html“ERR”过滤td,然后使用parent()获取其父tr并对其应用css
您可以使用以html“ERR”过滤td,然后使用parent()获取其父tr并对其应用css
您可以使用以html“ERR”过滤td,然后使用parent()获取其父tr并对其应用css
.parent()为我工作,请看小提琴:.parent()为我工作,请看小提琴:.parent()为我工作,请看小提琴:.parent()为我工作,请看小提琴: