Highlight td if its value is one
jquery
Solution
:contains is not a good fit for this as it just checks whether the given string is present anywhere in the element, use a manual filter to do it
$("table > tbody > tr > td").filter(function(){
return $.trim($(this).text()) == 'one'
}).css("background", "#6a5acd");
See demo at fiddle
Problem
I have a table like this. ``` <table> <tr> <td>one</td> <td>two</td> <td>one two</td> </tr> <tr> <td>one</td> <td>two</td> <td>one two</td> </tr> <tr> <td>one</td> <td>two</td> <td>one two</td> </tr> </table> ``` and jquery code to highlight the `td` if its value is `one` ``` $("table > tbody > tr > td:contains('one')").css("background", "#6a5acd"); ``` And code will make the td highligted if its value is `one two` also. I want to highlight only the td which have `one`