Using jQuery (or just JavaScript), how do I detect the inherited background-color of an element?
For example:
Hacky-Recursive answer
jQuery.fn.InheritedBackgroundColor = function(){
jQuery(this).parents().each( function(){
var bc = jQuery(this).css("background-color");
if( bc == "transparent" ){
return jQuery(this).InheritedBackgroundColor();
}
else{
return bc;
}
});
}
$(document).ready(function(){
if( $("#target").InheritedBackgroundColor() == rbga(255,0,0,0) ){
alert("Win!");
}
else{
alert("FAIL!");
}
});