简体   繁体   中英

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. 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?

See the jQuery .prev() and .next() functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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