Setting computed style property values

If all we wanted was to change the font size a single time to a predetermined value, we could still use the .addClass() method. But, let's suppose now that we want the text to continue increasing or decreasing incrementally each time the respective button is clicked. Although it might be possible to define a separate class for each click and iterate through them, a more straightforward approach would be to compute the new text size each time by getting the current size and increasing it by a set factor (for example, 40 percent).

Our code will start with the $(() => {}) and $('#switcher-large').click() event handlers:

$(() => {  $('#switcher-large')    .click((e) => {     }); }); 
Listing 4.1

Next, the font ...

Get Learning jQuery 3 - Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.