2

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

War10ck
  • 12,060
  • 7
  • 40
  • 51
Pacman
  • 2,113
  • 3
  • 37
  • 69

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,402
  • 3
  • 39
  • 52
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,648
  • 1
  • 15
  • 31