Skip to content

Instantly share code, notes, and snippets.

@bananabread
Created June 12, 2013 15:45
Show Gist options
  • Select an option

  • Save bananabread/5766522 to your computer and use it in GitHub Desktop.

Select an option

Save bananabread/5766522 to your computer and use it in GitHub Desktop.
jQuery Text Sizer
// 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