I have the JavaScript for converting a HEX value to RGB but I was wondering if I could use jQuery to call the function and insert the HTML?
Here\'s the JavaScript;>
valid hex colors can have 3 or 6 characters after the '#'
function hexToRgb(hex){
if(/^#([a-f0-9]{3}){1,2}$/.test(hex)){
if(hex.length== 4){
hex= '#'+[hex[1], hex[1], hex[2], hex[2], hex[3], hex[3]].join('');
}
var c= '0x'+hex.substring(1);
return 'rgb('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+')';
}
}