简体   繁体   English

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

[英]Style a Specfic Column of a specific Row of a Table

I have 我有

a table 一张桌子

在此输入图像描述


I want 我想要

to style a specific td of a specific row of a table. 设置表格特定行的特定td的样式。


I decided 我决定

to loop through each row , in each row, I loop through each td , and check if that td is equal to the one I want to check. 循环遍历每一row ,在每一行中,我循环遍历每个td ,并检查该td是否等于我想要检查的那个。


I tried 我试过了

$('#account-table').each(function () {
    $(this).find('td').each(function () {
      var td = $(this);
      if(td.innerText == 'vazogaxan@hotmail.com'){
        $(this).css('color','red');
      }

    });
});

I got 我有

I couldn't get that column text to be red . 我无法将该列文本变为红色

Any hints / suggestions ? 任何提示/建议?

innerText is a vanilla JS property, but you have a jQuery object and you try to access a inexistent property. innerText是一个vanilla JS属性,但你有一个jQuery对象,你试图访问一个不存在的属性。 Use text() method instead 请改用text()方法

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

More info: 更多信息:

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

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

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

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