vendredi 9 octobre 2015

Refresh page but keep checkboxes checked

I know I am a straight noob and I have tried a lot of different ways to get this jsfiddle to work like I want it to. But still no luck.

Im linking to the version where the first checkbox keeps its

http://ift.tt/1LErg1G

<input type="checkbox" id="yolo">
<input type="checkbox" id="yolo2">
<input type="checkbox" id="yolo3">


$(function(){
var test = localStorage.input === 'true'? true: false;
$('#yolo').prop('checked', test || false);
});

$('#yolo').on('change', function() {
localStorage.input = $(this).is(':checked');
console.log($(this).is(':checked'));
});

Basically I need all the checkboxes to save independently of each other. The context is so a user could check off things they can do and it will be there when they come back to the site. http://ift.tt/1LEreHa




Aucun commentaire:

Enregistrer un commentaire