Horje
convert rgb value in hexadecimal system Code Example
convert rgb value in hexadecimal system
    function convertRgb(rgb) {
  // This will choose the correct separator, if there is a "," in your value it will use a comma, otherwise, a separator will not be used.
  var separator = rgb.indexOf(",") > -1 ? "," : " ";


  // This will convert "rgb(r,g,b)" into [r,g,b] so we can use the "+" to convert them back to numbers before using toString 
  rgb = rgb.substr(4).split(")")[0].split(separator);

  // Here we will convert the decimal values to hexadecimal using toString(16)
  var r = (+rgb[0]).toString(16),
    g = (+rgb[1]).toString(16),
    b = (+rgb[2]).toString(16);

  if (r.length == 1)
    r = "0" + r;
  if (g.length == 1)
    g = "0" + g;
  if (b.length == 1)
    b = "0" + b;

  // The return value is a concatenation of "#" plus the rgb values which will give you your hex
  return "#" + r + g + b;
}




Javascript

Related
How to use vue.js in expressjs with pug Code Example How to use vue.js in expressjs with pug Code Example
svlete each index Code Example svlete each index Code Example
destructuring assignment in javascript Code Example destructuring assignment in javascript Code Example
isogram Code Example isogram Code Example
how do i activate my mangekyou sharingan Code Example how do i activate my mangekyou sharingan Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10