Using jQuery (or just JavaScript), how do I detect the inherited background-color of an element?
For example:
<div style="background-color: red">
<p id="target">I'd like to know that the background-color here is red</p>
</div>
However:
$('#target').css('background-color') == rgba(0,0,0,0)
and
$('#target').css('backgroundColor') == rgba(0,0,0,0)
I'm asking for a general solution. $('#target').parent().css('background-color')
would work in this instance, but not all.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…