How to implement Font Zoomer in JavaScript


Learn to implement Font zoomer in JavaScript. Some post has been posted with technical related stuff. Here for change I post Some JavaScript related stuff here.

Hope you all know basic of input types in HTML. Create a Simple html file with two Button, one is for increasing font size and another one is for decreasing font size.

In Html file:

<input type=”button” name=”button1″ value=”Increase Font Size” onclick=”increase()”>

<input type=”button” name=”button2″ value=”Decrease Font Size”onclick=”decrease()”>

Javascript Code:

var font_size = 1;
function increase() {
font_size += 0.1;
document.body.style.fontSize = font_size + “em”;
}
function decrease() {
font_size -= 0.1;
document.body.style.fontSize = font_size + “em”;
}

Advertisements

Tell us Your Suggestion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s