External CSS file…
#externalClass { font-family: arial; }
HTML file…
<a href="#" id="externalClass">Link</a>
JavaScript file…
console.log(jQuery("#externalClass").css("font-family"));
I get the “arial”, but not able to understand how it’s working (even in IE6/7/8/9) in native javascript?
Can someone explain it please.
It uses
getComputedStyle()(with necessary fallbacks such ascurrentStyle()) to calculate thefont-familyvalue.Source.
When you’re wondering how a library achieves something, the best way is to look at the source, and if you’re stuck comprehending it, then Google more or ask here 🙂