Keith, if you did want to use this code, please download it today, as I'll be cleaning off various test pages on this site soon.
JK -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jeffrey Kretz Sent: Saturday, March 22, 2008 8:36 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Darker on Click This may be completely overkill for what you need, but I've been building out a color utilities class for my color picker. It has conversions from RGB to HSV (hue/saturation/value) and back, as well as a color parser to and from a hex string. You can see a demo here: http://cobalt.scorpiontechnology.com/test/ColorTest.htm What I'm doing in this demo, is getting the RGB value of the current color, converting it to HSV and then reducing the value by 10% (which will make it darker), then converting it back to RGB. JK -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jason Huck Sent: Saturday, March 22, 2008 6:43 PM To: jQuery (English) Subject: [jQuery] Re: Darker on Click Well, CSS color values can be spec'ed as hex values, integers, or percentages (as well as names), so, you could parse the current value and increment/decrement the values accordingly. Here's a quick'n'dirty example: Using a div initially defined with a background-color like this: div { color: rgb(255,0,0); } ...you could decrement like so: $('div').click(function(){ var rgb = $(this).css('background-color'); rgb = rgb.substring(4,rgb.length - 1).split(', '); rgb[0] = parseInt(rgb[0]) - 51; var nrgb = 'rgb(' + rgb.join(',') + ')'; if(rgb[0] >= 0) $(this).css('background-color',nrgb); }); Something about that isn't quite right (it decrements one time too many), but you get the idea. HTH, Jason On Mar 22, 2:58 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I have a <div> that is currently pink. Every time that it is clicked, > I would like it to get redder until it is a dark red. > > I was wondering if anyone could think of an easy to implement this > with jquery. I can't think of any simple solutions that don't involve > storing the degrees of color in an array. > > Thanks! > Keith