based on this jquery that worked, how do I change it to color code a single cell instead of the whole row? I also need 3 colors

<script type="text/javascript">

    $("td.ms-vb2").each( function () {

       if($(this).text() == "VALUE"){
       $(this).parent("tr").css("background-color", "#F5A9A9");
       //$(this).closest("tr").css("background-color", "#F5A9A9");



1 Answer 1


Try this

$("td .ms-vb2:contains('value')").css("color", "Red");

Or in your code, in if condition, try to use

$(this).css("background-color", "#F5A9A9");
  • it does not work (tried the second one)
    – susan
    Sep 5, 2018 at 13:54
  • do you have any issue to try the first one!!! Sep 5, 2018 at 13:55
  • That i would have to change the whole code and i am not able to, I have replaced the IF line and THIS line with your one single line and it does not work, if you could please post the whole code it would be better
    – susan
    Sep 5, 2018 at 14:01
  • ok, this code works with lists but when I applied it to the library 'Pages' it does not work, do I need to change something? the 'cell' of pages is still td.ms-vb2
    – susan
    Sep 11, 2018 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.