you should use descendant selector for the table and the tr element
$( "#TableID tr:contains('" + x + "')").css( "background-color", "red" );
Your code looks for a table with id TableID
with class tr
and contains the given text some where within it