Changing Font Size with JavaScript
Click the buttons below to change the font size of this text.
function increaseFontSize() {
var text = document.getElementById(“text”);
var currentSize = window.getComputedStyle(text, null).getPropertyValue(‘font-size’);
var newSize = parseInt(currentSize) + 2;
text.style.fontSize = newSize + “px”;
}
function decreaseFontSize() {
var text = document.getElementById(“text”);
var currentSize = window.getComputedStyle(text, null).getPropertyValue(‘font-size’);
var newSize = parseInt(currentSize) – 2;
text.style.fontSize = newSize + “px”;
}