如何更改表格行的背景颜色 [英] how to change background color of a table row

查看:110
本文介绍了如何更改表格行的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为表格设置背景颜色,

i在我的代码中写了这样的东西



表格id是:datatable



$('tr')。each(function(){

if($(this).find('td') .eq(4).text()。trim()===yes){

$(this).css('background','green');

}



});



工作正常,但问题是颜色正在应用交替行值,我的意思是假设两行包含文本值是它只适用于第二行值而不是第一行,就像这是应用,但我需要将颜色设置为文本值的行包含是,请帮我解决这个问题?



注意:所有数据都是动态的!!!!!!!!!!

解决方案

('tr')。each(function(){

if(


(this)。找到( '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!!!!!!!!!!

解决方案

('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!!!!!!!!!!


这篇关于如何更改表格行的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆