Thanks a bunch, that's very handy code. :)
 

Luke Lutman wrote:
> 
> 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/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Find-first-parent-element-with-certain-style-tf3429157.html#a9562274
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to