Created
May 25, 2017 01:08
-
-
Save paceaux/fb1eddcb468466dd77aeb046015277e1 to your computer and use it in GitHub Desktop.
Convert Color Name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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