Yansky wrote: > I'm having a bit of trouble figuring out how to do this. What I'd like to do > is find the first parent element that has a background color that is not > transparent. > > This is what I've tried so far, but with no success: > > $('.elemToFade:first').parents("[EMAIL PROTECTED] != > 'transparent']:first"); > > this also didn't work: > > $('#theDiv').parents().each(function(i){ > if($(this).css("backgroundColor") != "transparent"){ > return.this[0];} > });
Here's a snippet I've used in the past: var bgcolor = function(el) { var color = jQuery(el).css('background-color'); if(/^(rgba|transparent)/.test(color) && el.parentNode) return arguments.callee(el.parentNode); return color; }; Use it like this: var mybgcolor = bgcolor($('#myelement')[0]); Luke -- zinc Roe Design www.zincroe.com (647) 477-6016 _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/