Last active
January 12, 2016 17:17
-
-
Save designfrontier/1127a85cdb819be1a918 to your computer and use it in GitHub Desktop.
get Background color
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
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; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this should end up in belt eventually...