tags:

views:

233

answers:

3

How is it possible that, being 'colonna' a simple string:

$('td.' + colonna).css('background-color','#ffddaa');

works correctly highlighting the background of the interesting cells, and:

$('td.' + colonna).contains('Catia').css('background-color','#ffddaa');

produces the error: "$('td.' + colonna).contains is not a function"?

Someone has an idea?

Thanks!

A: 

I don't have the specific answer, but it sounds like you would gain a lot by using a good JS debugger. I'd recommand Firebug.

Explanations on how to use it here: http://getfirebug.com/js.html

Like this you will be able to see the DOM, the different functions availables. If it doesn't fix it you'll still be able to post a more precise question.

Sorry for not being more helpful

marcgg
+8  A: 

I believe it should be something like:

$('td.' + colonna + ":contains('Catia')").css('background-color','#ffddaa');
Benny Wong
You are right... it is. Thanks a lot!
Daniel
I'm confused because of this: http://docs.jquery.com/Traversing/containsI have been learning jQuery through "jQuery in Action" (too lazy to look up a link; it's a popular book though) and in my Oct. 2008 edition on p.45 they list a "contains" function. Both their example, and the one I linked to above from the jQuery docs, generate the OP's error ("not a function"). Did there used to be a .contains function that maybe got removed? Or did it get added after 1.2.1, the version used in the book's sample code?
Coderer
A: 

I know this is way (way!) past due, but I asked another question and it would appear that the net result is "old versions of JQuery had a .contains() method, but it has been deprecated." Yay for breaking your API!

Coderer