Selaa lähdekoodia

Listing 4.4: increase/decrease font size.

Frederic G. MARAND 8 vuotta sitten
vanhempi
säilyke
c9c121eb62
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. 6 2
      Chapter 4/04.js

+ 6 - 2
Chapter 4/04.js

@@ -2,9 +2,13 @@ $(document).ready(function () {
   "use strict";
 
   var $speech = $('div.speech');
-  $('#switcher-large').click(function () {
+  $('#switcher button').click(function () {
     var num = parseFloat($speech.css('fontSize'));
-    num *= 1.4;
+    if (this.id == 'switcher-large') {
+      num *= 1.4;
+    } else if (this.id == 'switcher-small') {
+      num /= 1.4;
+    }
     $speech.css('fontSize', num + 'px');
   });
 });