I'am not sure, but this one may be faster:// get the background color var current_p = $(this); var bg = "transparent"; while(bg == "transparent") { bg = current_p.parent().css('background-color'); current_p = current_p.parent(); }
you have a parent() too many ;-) anyway this will fail if everything is transparent: you'll hit the document as $('html').parent() and get a js error when doing .css() on it. -- Fil