我有一个HTML表格,一些单元格将为空,我可以找到空单元格并替换该值,但我想知道如何检查单元格是否为值,如果是,则进行更改
到目前为止,我可以更改所有单元格,或只更改空单元格,但我想知道如果单元格不为空,如何进行更改。
<table id="SearchTable" class="table table-striped" style="text-align: justify">
<tr>
<th>
</th>
<th>
Report Detail
</th>
<th>
Form
</th>
<th>
Attachments
</th>
<th>
Result
</th>
<th>
Report No.
</th>
<th>
Report Date
</th>
<th>
Form No.
</th>
</tr>
<tr style="text-align:center">
<td class="reportManager">
</td>
<td class="reportDetail">
<span style="opacity: 0.349019607843137; font-size: 40px;"><i class="fa fa-file-text-o"></i></span>
</td>
<td class="form">
<span style="opacity: 0.349019607843137; font-size: 40px;"><i class="fa fa-pencil-square-o"></i></span>
</td>
<td class="attachments">
<span style="opacity: 0.349019607843137; font-size: 40px;"><i class="fa fa-paperclip">
</i></span>
</td>
<td class="result">
Success
</td>
<td class="reportNo">
Rpt-001001110
</td>
<td class="Date">
08-09-2012
</td>
<td class="formNo">
A000146647
</td>
</tr>
</table>
$("#SearchTable").find("td.reportManager:not(:empty)").html('<span style="opacity: 0.349019607843137; font-size: 40px;"><i class="fa fa-file-o"></i></span>')
答案 0 :(得分:4)
而不是:not(:empty)
,使用$("#test").find("td.def:not(:empty)").html('<strong>not empty<strong/>')
查找不空的单元格:
{{1}}
<强> jsFiddle example 强>