What's preventing this from working?
localStorage.fontSize
contains the correct value, but the initial
document.body.style.fontSize = localStorage.fontSize + "pt";
doesn't update the style.
<script type="text/javascript>
if(!localStorage.fontSize){
localStorage.fontSize = Number(11);
}
else{
document.body.style.fontSize = localStorage.fontSize + "pt"; /* This line isn't executed */
}
function resetFont(){
localStorage.fontSize = Number(11);
document.body.style.fontSize = "11pt";
}
function enlargeFont(){
localStorage.fontSize++;
document.body.style.fontSize = localStorage.fontSize + "pt"; /* However this one works when called */
}
</script>
Please refrain from using jQuery snippets.