'jQuery to change background on table row based on values of two cells within that row

I have a tampermonkey script that highlights table rows when specific columns contain specific text.

For example the code below successfully highlights rows were column 1 contains 'M' and rows where column 3 contains 'P'.

$("td:nth-of-type(1):contains('M')").parent().css("background-color","#ccccff");
$("td:nth-of-type(3):contains('P')").parent().css("background-color","#ccccff");

How can I use an AND operator or an IF statement to highlight a row only if column 1 contains 'P' AND column 3 contains 'M'?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source