设置表格特定行的特定列的样式

时间:2016-03-07 15:30:40

标签: jquery css html-table

我有

enter image description here

我想要

设置表格特定行的特定td的样式。

我决定

遍历每个row,在每一行中,我循环遍历每个td,并检查td是否等于我要检查的那个$('#account-table').each(function () { $(this).find('td').each(function () { var td = $(this); if(td.innerText == 'vazogaxan@hotmail.com'){ $(this).css('color','red'); } }); });

我试过

{{1}}

我得到了

我无法将该列文字红色

任何提示/建议?

1 个答案:

答案 0 :(得分:3)

innerText是一个vanilla JS属性,但你有一个jQuery对象,你试图访问一个不存在的属性。请改用text()方法

 if(td.text() == 'vazogaxan@hotmail.com'){

更多信息:

http://api.jquery.com/text/

https://developer.mozilla.org/es/docs/Web/API/Node/innerText