In jQuery, we can easily get the CSS value for a given element with the css
method:
$('#myElement').css('line-height'); // e.g. '16px'
Now, since this CSS value might have been inherited from a parent element, is there any way to know which element has this rule applied to it?
For example, let's say I have the following HTML:
<div class="parent">
<div id="myElement"></div>
</div>
and the following CSS:
.parent {
line-height: 20px;
}
Calling the css
method on #myElement
will return 20px
, but it will not indicate that it was inherited from .parent
.
I know I can just fire up Web Inspector
/Dev Tools
/Firebug
, but I want to get it programmatically.
Is this at all possible?