I am unable access the font size of an SVG text element through Javascript.
The setup is as follows:
<svg class='outer' width='900' height='625'>
<text class='graph-title' x='450' y='25'>My Title</text>
</svg>
The style of 'graph-title' is set in a separate CSS file as follows:
.graph-title {
alignment-baseline: middle;
font-family: Roboto;
font-size: 1.6em;
text-anchor: middle;
}
Javascript can set the font size as follows:
var graphTitle = document.getElementsByClassName('graph-title')[0];
graphTitle.style.fontSize = '10em'; //Title gets much bigger.
However, when I attempt to read fontSize--without first setting it in Javascript--I get the empty string:
console.log(`|${graphTitle.style.fontSize}|`); //outputs ||
Is there some way for Javascript to read the font size that is set by the CSS file?