gpt4 book ai didi

html - 如何使用 css 更改 html 表格中每个单词实例的颜色?

转载 作者:太空宇宙 更新时间:2023-11-04 09:45:47 25 4
gpt4 key购买 nike

我使用 AngularJS 在 html 中有下表:

<table id="searchTable">
<thead>
<tr>
<th>Index</th>
<th>Observation</th>
<th>Reported By</th>
<th>Verified By</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="observation in observations| filter:searchText">
<th> {{$index + 1}} </th>
<th>{{observation.clinicalType}}</th>
<th>{{observation.reportedBy}}</th>
<th>{{observation.verifiedBy}}</th>
<th>{{observation.reportedDate}}</th>
</tr>
</tbody>
</table>

在“Observations”、“Reported By”、“Verified By”和“Date”列中,可能有字符串“NULL”。我想知道 CSS 中是否有一种快速简便的方法可以将所有四列中的每个“NULL”实例都涂成红色?我已经被困在那里很长一段时间了。

最佳答案

我个人建议在 Jquery 中执行此操作。您可以查找所有 <th>包含“NULL”的元素并通过执行以下操作将它们更改为红色...

$(document).ready(function() {

$("th:contains('NULL')").css("color", "red");

});

JSFiddle: https://jsfiddle.net/97oqnuyx/

编辑:因为您欣然接受了我的回答,但它实际上似乎并没有解决您具体情况下的问题,我觉得我应该确保我没有传播错误信息万一人们发现这个。

虽然我上面的回答在很多情况下都有效,但如果您使用的是 Angular,这可能不是正确的方法。在那种情况下,您正在寻找更像 this one 的解决方案,在上面的评论中链接到哪个 OP。

关于html - 如何使用 css 更改 html 表格中每个单词实例的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39517511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com