Skip to content

Instantly share code, notes, and snippets.

@designfrontier
Last active January 12, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designfrontier/1127a85cdb819be1a918 to your computer and use it in GitHub Desktop.
Save designfrontier/1127a85cdb819be1a918 to your computer and use it in GitHub Desktop.
get Background color
getComputedBG = function (elem) {
var rtn = window.getComputedStyle(elem)['background-color'],
element = elem,
isTransparent = function (color) {
return color === 'rgba(0, 0, 0, 0)' || color === 'transparent'
};
while (element !== null && isClear(rtn)) {
element = element.parentElement;
rtn = window.getComputedStyle(element)['background-color'];
if (!isTransparent(rtn)) {
break;
}
}
return rtn;
};
@designfrontier
Copy link
Author

this should end up in belt eventually...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment