0

How could jQuery contains used for select exact string?

Here is a working code for setting the row colour in every table row which contains the string tree.

$( "#AnsprechpartnerTabelle tr:contains('" + x + "')").css( "background-color", "red" );    

The problem is that rows which has "treeapple" as content are selected too.

So how could it build that it works like the userstory?

Joofe Kopp
  • 123
  • 2
  • 13

1 Answers1

3

Use:

$("#AnsprechpartnerTabelle tr").filter(function() {
return $(this).text() === x;
}).css( "background-color", "red" );  
Satpal
  • 129,808
  • 12
  • 152
  • 166
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120