0

I am getting the color property of an element using:

getComputedStyle(element).getPropertyValue(
    "color"
  );

which gives me the rgb color code, Is there a way to get this in hex format? since I am traversing the whole DOM so I want to save some effort of converting each of them to hex value using some custom function.

Edit: I have gone through the other answers, but that's not what I am looking for. I want to get it from the element rather than converting all of them later on.

bhansa
  • 7,282
  • 3
  • 30
  • 55
  • 1
    https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb –  Sep 20 '18 at 16:36
  • I know about all these solutions, I don't want to do it for each and every element when I am traversing through the DOM. – bhansa Sep 20 '18 at 17:18
  • "*I want to get it from the element rather than converting all of them later on.*" a) you can't b) what difference would it make? How would your code look when you used that solution (please post it), and what is the problem with that? – Bergi Sep 20 '18 at 17:55

0 Answers0