How do I detect the inherited background-color of an element using jQuery/JS?

This could be accomplished by using the parent() in a loop until you reach the body tag:

I’ve set up a quick jsfiddle site with a little demo based on your code.

Edit:
Good catch fudgey. After doing some testing it appears that IE7 will return 'transparent' instead of the rgba(0,0,0,0) value. Here’s an updated link which I tested in IE7, Chrome 7, and Firefox 3.6.1.2. Another caveat with this approach: Chrome/Firefox will return rgb(255,0,0); IE returned 'red'.

Leave a Comment