Xpode.com        Click here to Print this article.

Font Resizing with Javascript

In this trick you can resize the font of specific tag with a click on specifuc word. In this example we will use span tag. Below you are seeing text in a rectangle. That is placed in span tag. Now click on the text written on that box named "Font Increase" or "Font Decrease" to change the size of box text.

To do this just write the javascript code given below:

 < script type="text/javascript" language="javascript";>

var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('span');

Place the word in span tag like in this example.

     < p style="width: 500px; border: solid 2px blue;"  >
     This is test text. To resize Plase click on the "Font Increase" or "Font Decrease"
     to change the size of box text.  

and call both javascript functions on two links. Like given below.

< a href="javascript:increaseFontSize();">Font Increase

< a href="javascript:decreaseFontSize();">Font Decrease


Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com

Click here to go on website