Skip to content

Instantly share code, notes, and snippets.

@kaotikus
Created November 24, 2015 03:14
Show Gist options
  • Save kaotikus/08bb07ba2ef17727ed2b to your computer and use it in GitHub Desktop.
Save kaotikus/08bb07ba2ef17727ed2b to your computer and use it in GitHub Desktop.
simple example of fontSize switcher in jQuery
// simple example of fontSize switcher in jQuery
$(document).ready(function() {
var $speech = $('div.speech');
var defaultSize = $speech.css('fontSize');
$('#switcher button').click(function() {
var num = parseFloat($speech.css('fontSize'));
switch (this.id) {
case 'switcher-large':
num *= 1.4;
break;
case 'switcher-small':
num /= 1.4;
break;
case 'switcher-default':
num = parseFloat(defaultSize);
}
$speech.css('fontSize', num + 'px');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment