I have this table
<table> <tr> <td>Name</td> <td>John Stevenson</td> </tr> <tr> <td>Name</td> <td>John Stevenson</td> </tr> <tr> <td>Name</td> <td>Jack Stevenson</td> </tr> </table> How can I find if there is "Jack Stevenson" and if it true, set this td color to red.
My jQuery code not works:
$("table").find("td").each(function () { var hiImJohn = $("td:contains('John Stevenson')"); var td = $(this).text(); if ( td.indexOf("John Stevenson") > 0 ) { hiImJohn.css({color: "red"}); } });