Hi,
> function RGBToHex(value)
> {
> var re = /\d+/g;
> var matches = value.match(re);
> var r = parseInt(matches[0]);
> var g = parseInt(matches[1]);
> var b = parseInt(matches[2]);
> return "#" + r.toString(16) + g.toString(16) + b.toString(16);
> }
function RGBToHex(value) {
var re = /\d+/g;
var matches = value.match(re);
for( var i = 0; i < matches.length; i++ ) {
matches[i] = parseInt(matches[i]).toString(16);
if( matches[i].length < 2 ) matches[i] = '0'+matches[i];
}
return "#" + matches[0] + matches[1] + matches[2];
}
Otherwise you will get #ff00 from rgb(255,0,0)
Christof
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/