javascript - Need a cookie to save the size of the font -


i have written code resizes fonts when user clicks on 'increase' or 'decrease' , set cookie save fontsize of browser 5-7 days.

the jquery here:

$('.fontinc').on("click", function() {     // increase current size 1     currentsize = parseint($('body').css('font-size')) + 1;      if(currentsize <= 20)         $('body').css('font-size', currentsize); });  $('.fontdec').on("click", function() {     // decrease current size 1     currentsize = parseint($('body').css('font-size')) - 1;      if(currentsize >= 12)         $('body').css('font-size', currentsize); }); 

now assumed if wrote $.cookie("savefontsize", currentsize, {path:'/', expires: 5}); save 'currentsize' 5 days refresh browser font returns default...

what doing wrong? need see html?

i'd you're missing part read cookie on pageload.

$(document).ready(function(){   $('body').css('font-size', $.cookie('savefontsize')); } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -