gpt4 book ai didi

JQuery 表格突出显示使用条件

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

我使用 Datatables在我的页面上创建几个表。我想用 jquery highlighting插件来突出显示某些不正确的元素。例如,“已启用”列中的所有内容都应为“真”,如果不是真,则应突出显示。但是,在“级别”列中,它们应该是“假”。谁能帮我完成这个?

这是表格的一个例子:

+-------------+------------+----------+
| Cluster | Enabled | Level |
+-------------+------------+----------+
| 1 | True | False |
| 2 | True | True |
| 3 | False | True |
| 4 | True | False |
| 5 | False | False |
| 6 | False | True |
+-------------+------------+----------+

这是我用来玩的 JSFiddle:http://jsfiddle.net/t7f7m3hr/1/

谢谢!!

最佳答案

您可以在 td 元素上使用 :nth-child() 选择器:

//Need to highlight 'Enabled' column if = True
$('#example td:nth-child(2)').highlight('True');

//Need to highlight 'Level' column if = False
$('#example td:nth-child(3)').highlight('False');

演示:http://jsfiddle.net/jtbowden/4vwxqpz5/

关于JQuery 表格突出显示使用条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25436946/

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