How to increment font size changes with jQuery?

Alfred picture Alfred · May 12, 2011 · Viewed 44.2k times · Source

Hi I want to change the font size of the page incrementally with jQuery how do I do that?

Something like:

$('body').css({'font-size':'+.01px'});
$('body').css({'font-size':'-.01px'});

Answer

Sylvain picture Sylvain · May 12, 2011

You could do so :

var fontSize = parseInt($("body").css("font-size"));
fontSize = fontSize + 1 + "px";
$("body").css({'font-size':fontSize});


jsFiddle example here