2

I am using angular, but I assume I can use any DOM manipulation for this ?

War10ck
  • 12,387
  • 7
  • 41
  • 54
Pacman
  • 2,183
  • 6
  • 39
  • 70

2 Answers2

7

You can use getComputedStyle() and getPropertyValue().

Here's a running example:

var test = document.getElementById("test");
var result = document.getElementById("result");
result.value = getComputedStyle(test).getPropertyValue("font-family");
#test {
  font-family: "Trebuchet MS",sans-serif;
}
<span id="test">What font family am I?</span>
<input id="result"></input>
Dave
  • 10,748
  • 3
  • 43
  • 54
2

If you have jQuery you can use this:

$('#some-selector').css('font-family');

You can use vanilla JS too, but it is a bit more involved. Here is an example using getComputedStyle: getComputedStyle in pure Javascript?

Community
  • 1
  • 1
vakata
  • 3,726
  • 1
  • 17
  • 31