doudun8705
doudun8705
2014-04-06 08:23

如何使用jquery更改表格单元格颜色

  • php
  • html
  • javascript
  • jquery

I having a html table with inline edit function,when the user edit the td if the value enter by user lower than zero the td color for specific cell would change without refreshing the page.

For example: if cell =< "-1", background-color=#FF0000

there is any way to make this work in reality?

$("#table td").each( function() {
    var thisCell = $(this);
    var cellValue = parseInt(thisCell.text());        
    if (!isNaN(cellValue) && (cellValue >=0)) {
        thisCell.css("background-color","#FF0000");
    }
});
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答