how to convert rgb color to color name string in javascript
let btn = document.querySelector("#demo");
let css = getComputedStyle(btn);
console.log(css.color);
output is in rgb value rgb (255,0,0)
how to convert rgb color to color name string in javascript
let btn = document.querySelector("#demo");
let css = getComputedStyle(btn);
console.log(css.color);
output is in rgb value rgb (255,0,0)
Copyright © 2021 Jogjafile Inc.
You need to convert the RGB string to a hex value, and then you can compare it against a list like this of HTML color names.