Can I make a table cell have a different background color if the value =< a particular number with jquery or PHP?

前端 未结 5 506
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 17:31

I have an HTML table with a lot of numbers.

Is it possible to have a table cell change background color if the value inside that cell (or column) equals or is less than

5条回答
  •  暖寄归人
    2021-01-28 18:20

    Yes it is easy to do this sort of thing.

    For example, with jQuery, something like this:

    $('table.mytable td').each(function() {
      if (this.textContent <= 3000) {
        $(this).css('background', '#FF0000');
      }
    }
    

提交回复
热议问题