This question already has an answer here:
- How To Get Font Size in HTML 5 answers
I have tried:
document.getElementById("foo").style.fontSize
However that returns nothing. My CSS is defined in the same document and not a separate stylesheet. I have also tried this:
var el = document.getElementById("content");
var style = window.getComputedStyle(el, null).getPropertyValue("font-size");
var fontSize = parseFloat(style);
el.style.fontSize = (fontSize + 1) + "px";
but that doesn't work.
This is the html in question:
<p contenteditable="true" id="content">Write here. Seriously, try it.</p>
And this is the css
#content {
line-height: 30px;
margin-top: 22px;
min-height: 90%;
display: block;
padding: 0 20px 0 20px;
font-size:15px;
}
Aucun commentaire:
Enregistrer un commentaire