JQuery resize cookie based font size?

I am trying to create a text resizer that also sets a cookie depending on what the user has chosen as the font size for the website. It creates a cookie, but I cannot force it to resize the body text as soon as the page is loaded initially. Any help would be appreciated.

The code:

  var origFont = parseFloat($("body").css("font-size"), 10);
  var cookieFont = $.cookie("fontSize");

  if (!cookieFont) {
    var curFont = origFont;
    $("#content").css("font-size", curFont);
  } else {
    var curFont = $.cookie("fontSize"); 
    $("#content").css("font-size", curFont);
  };

I use the same code to change the font size when you click on the increase / decrease, but it does not work to change the main text after loading the page.

ADDITION: I just checked this in IE and it works fine, but not in FF, now it will check other browsers ...

Well, this works in IE and Opera, but not in Firefox, Chrome or Sarafi.

+3
source share
2

unit.

-

$("#content").css("font-size", curFont + 'px');

font-size Firefox 3.6, (FF px , ), Chrome 9 .

+5

Source: https://habr.com/ru/post/1791354/


All Articles