Lets say I have a RGB value of (0, 255, 0), how do I put that in a function which returns the hex value of it like below:
var rgbColor = div.backgroundColor; // Is stored as a rgb value
var hexVersion = rgbToHex(rgbColor);
function rgbToHex(rgb) {
// Some code
//return hex
}
The aim of this is to select a different element and set an input[type="color"]'s value to the background colour of an element but the only value you can set must be a hex so I need to convert the rgb to hex to do so, if anyone could help I would appreciate it greatly, thank you.