Reputation: 73
I'm doing the first two pages of received data from the form and stores it in localStorage:
<form id="myForm" method="post">
font-size px: <input id="fontsize" type="text" name="fontsize" />
</form>
<script type="text/javascript">
var inpX = document.getElementById('fontsize');
var x = parseFloat(inpX.value);
localStorage.setItem('inpX', x);
on the second page write the code jquery increases the font:
$(document).ready(function(){
var fontsX = localStorage.getItem('inpX');
$("#info").css('font-size':'fontsX +'px'');
});
but nothing happens. what am I doing wrong?
Upvotes: 1
Views: 86
Reputation: 193261
Colon is used for object notation (when you pass an object of properties). So one more version to set css property:
$("#info").css({'font-size': fontsX + 'px'});
or even shorter
$("#info").css({fontSize: fontsX + 'px'});
since jQuery will normalize snake-case names to cameCase.
Upvotes: 2
Reputation: 388316
You have syntax issues, you need to pass the css property and value as 2 arguments or pass a object
$("#info").css('font-size', fontsX +'px');
Upvotes: 1