Skip to content

Instantly share code, notes, and snippets.

@designfrontier
Last active January 12, 2016 17:17
Show Gist options
  • Select an option

  • Save designfrontier/1127a85cdb819be1a918 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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