In jQuery, we can easily get the CSS value for a given element using the css method:
$('#myElement').css('line-height'); // eg '16px'
Now, since this CSS value could be inherited from the parent element, is there a way to find out which element this rule applies to?
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 that I can just launch Web Inspector / Dev Tools / Firebug , but I want to get it programmatically.
Is it possible?
source share