Created
September 13, 2010 04:18
-
-
Save 0xnbk/576801 to your computer and use it in GitHub Desktop.
Font resizing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// Reset Font Size | |
var originalFontSize = $('html').css('font-size'); | |
$(".resetFont").click(function(){ | |
$('html').css('font-size', originalFontSize); | |
}); | |
// Increase Font Size | |
$(".increaseFont").click(function(){ | |
var currentFontSize = $('html').css('font-size'); | |
var currentFontSizeNum = parseFloat(currentFontSize, 10); | |
var newFontSize = currentFontSizeNum*1.2; | |
$('html').css('font-size', newFontSize); | |
return false; | |
}); | |
// Decrease Font Size | |
$(".decreaseFont").click(function(){ | |
var currentFontSize = $('html').css('font-size'); | |
var currentFontSizeNum = parseFloat(currentFontSize, 10); | |
var newFontSize = currentFontSizeNum*0.8; | |
$('html').css('font-size', newFontSize); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Font resizing
Font Resizing is a very common feature in many modern websites. Here’s how to do it with JQuery.