Is there a way to check an elements parents and find the first one that has a CSS background set and then return that background value?
Something like:
I'd try something like this:
var background = 0;
$('element').parents().each(function() {
if (!background && ((e = $(this).css('background')).length > 0)) background = e;
});
Not sure if this exact if-clause works, but the each() should do the trick. The first match will fill the background variable and ignore the rest of the parents while traversing up in the chain.
Edit: Amended to resolve css('background') correctly which may emit an empty string. Additionally, each() does not pass the element, but index and element, thus make use of this instead and discard all parameters.