简体   繁体   English

Javascript/JQuery - 在具有特定值的单元格前后更改 HTML 表格单元格的背景颜色

[英]Javascript/JQuery - Change background color of HTML table cells before and after cell with a specific value

I'm currently trying to change HTML table cells before and after I find a cell with a value of 76. The cells before and after are string values.我目前正在尝试在找到值为 76 的单元格之前和之后更改 HTML 表格单元格。之前和之后的单元格是字符串值。 I was able to get the whole row to change background color based on the one cell value, but not what I want.我能够让整行根据一个单元格值更改背景颜色,但不是我想要的。

var r = $(this).data('row');
if(/76/.test(r.where.m_cur_state_id) && timeInOper >= 0){
$(this).css( "background-color", "red" );
$(this).children().css('color','#FFF');         
}

Any direction on how to make the cell with value of 76 red and the cell before and after red?关于如何使值为 76 的单元格和红色前后的单元格的任何方向?

See the jQuery .prev() and .next() functions.请参阅 jQuery .prev().next()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM