Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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');
   for(i=0;i

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

Share this article   |    Print    |    Article read by 3179 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: No related interview question