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
  • 132,252
  • 13
  • 159
  • 168
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125