Jquery or javascript function to convert color from rgb to hex

by rajesh 2012-12-07 17:01:30

function rgb2hex(rgb) {
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
1004
like
0
dislike
0
mail
flag

You must LOGIN to add comments