Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  61] [ 5]  / answers: 1 / hits: 42304  / 13 Years ago, tue, november 8, 2011, 12:00:00

I am theming some report tables and do not have access to the templates.



I have this code so far which ends up adding my-class to every TR element in the report table. However, I only want to add the class to the table row TR where the text was found. I am thinking I need a little more code to do this. Here are a few things I have tried so far:



if ($('#report-area table tr:contains(Name)', this).length > 0) {
$(#reportArea table tr, this).addClass(my-class);
}


I have also tried:



if ($('#report-area table tr:contains(Name)', this).length > 0) {
$(this).addClass(my-class);
}


... but that did not work either.


More From » jquery

 Answers
4

Just use the selector with no fluff:



$('#report-area tr:contains(Name)').addClass('my-class');


http://api.jquery.com/contains-selector/


[#89234] Monday, November 7, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jananauticat

Total Points: 1
Total Questions: 105
Total Answers: 95

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;