Created
November 24, 2015 03:14
-
-
Save kaotikus/08bb07ba2ef17727ed2b to your computer and use it in GitHub Desktop.
simple example of fontSize switcher in jQuery
This file contains 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
// 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