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 believe the correct way to do this is to check the .length property.
In your case you'd want to loop through all of your elements and check for the first one that meets
.css('background').length != 0