Skip to content

Instantly share code, notes, and snippets.

@paceaux
Created May 25, 2017 01:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paceaux/fb1eddcb468466dd77aeb046015277e1 to your computer and use it in GitHub Desktop.
Save paceaux/fb1eddcb468466dd77aeb046015277e1 to your computer and use it in GitHub Desktop.
Convert Color Name
function convertColorName (name) {
var testEl = document.createElement('div'),
rgb;
testEl.style.backgroundColor = name;
rgb = document.body.appendChild(testEl);
rgb = window.getComputedStyle(testEl).backgroundColor;
document.body.removeChild(testEl);
return rgb;
}
/*
var salmon = converColorName('salmon');
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment