JavaScript - Dynamic Font Resizer

In this tutorial we will create a Dynamic Font Resizer using JavaScript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It is a text-based programming language meant to run as part of a web-based application. It is an interpreted programming language that has a capabilities of Object-Oriented. So Let's do the coding...

Getting started:

First you have to download bootstrap framework, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

Creating The Interface

This is where we will create a simple form for our application. To create the forms simply copy and write it into your text editor, then save it as index.html.

JavaScript - Dynamic Font Resizer



Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.

Creating the Script

This code contains the script of the application. This code will change the font size dynamically based on user input. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js folder. function resizeFont(){ var size = document.getElementById('size'); if(size.value.length > 0){ var result = document.getElementById('result'); result.style.fontSize = size.value+"px"; size.value = ""; }else{ alert("Please enter something first!"); } } There you have it we successfully created a Dynamic Font Resizer using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!

Add new comment