tags:

views:

156

answers:

4

hi,

could you explain me why the following code doesn't work in Chrome and Safari, but only in Firefox ?

if ($(this).css("color") == "Fuchsia"){ $(this).css("color","#000000"); }

This is the link:

http://www.sanstitre.ch/drupal/portfolio?tid[0]=38

If you scroll down and up you'll see "Eternal Tour" becoming purple and black again, because it is not anymore selected. (with FIrefox)

With Chrome and Safari it remains black.

A: 

I would trace what returns $(this).color() and see, but I would say that the main problem is, that chrome/safari both return hex code, so comparing against string doesn't work.

try to compare it against #FF00FF.

Adam Kiss
A: 

Try this

if ($(*).css("color") == "fuchsia"){ $(this).css("color","#000000"); }
Tim
I'd avoid this. Not a good idea to loop through every element on the page
Ilya Biryukov
A: 

I've changed Fuchsia to fuchsia and it worked! thanks

Patrick
A: 

Try to spell it lowercase: fuchsia.

powtac