By Clicking the (+) button font will be increased and if we click the (-) button font will be decreased. Enjoy!
HTML, CSS and JavaScript code below:
<!DOCTYPE html>
<html>
<body>
<p id="article_description">This is a paragraph.</p>
<button type="button" onclick="increaseFont()" style="margin:5px; padding:5px 10px;">+</button>
<button type="button" onclick="decreaseFont()" style="margin:5px;padding:5px 10px">-</button>
<script type="script/javascript">
var i=14;
function increaseFont() {
if(i>25)
{
i;
}
else
{
i++;
document.getElementById("article_description").style.fontSize = i+"px";
}
}
function decreaseFont() {
if(i>12)
{
i--;
document.getElementById("article_description").style.fontSize = i+"px";
}
else
{
i;
}
}
</script>
</body>
</html>