问题描述
我想为表格设置背景颜色,
i在我的代码中写了这样的东西
表格id是:datatable
$('tr')。each(function(){
if($(this).find('td') .eq(4).text()。trim()===yes){
$(this).css('background','green');
}
});
工作正常,但问题是颜色正在应用交替行值,我的意思是假设两行包含文本值是它只适用于第二行值而不是第一行,就像这是应用,但我需要将颜色设置为文本值的行包含是,请帮我解决这个问题?
注意:所有数据都是动态的!!!!!!!!!!
i want to set background color to a table ,
i have written something like this in my code
table id is: datatable
$('tr').each(function () {
if ($(this).find('td').eq(4).text().trim() === "yes") {
$(this).css('background', 'green');
}
});
it is working fine, but problem is color is applying to alternation rows values, i mean suppose if two rows contains text value "yes" it is applying to only second row value not to the first one, like this is applying ,but i need to set the color to the rows where ever text value contains "yes", please help me how to solve this?
Note:All data is coming dynamically!!!!!!!!!!
这篇关于如何更改表格行的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!