/ Published in: JavaScript
You have a RGB value and want to convert it into Hexadecimal mode, here’s how to do it using JavaScript.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function Rgb() { var red = returnHex(200); var green = returnHex(255); var blue = returnHex(155); var hex = "#" + red + green + blue; alert(hex); } // Convert to Hex function returnHex(num) { // Hex can store 16 different values in 1 character if (num == null) return "00"; num = num.length < 2 ? "0" + num : num return num.toString(16); }
URL: http://www.devcurry.com/2010/08/convert-rgb-to-hexadecimal-using.html