javascript - check / uncheck a single checkbox using jquery -
i have single html page 30+ check boxes (
how configure script remember check box selected (remember 1 checked or unchecked)
this script use:
$(function(){ var test = localstorage.input === 'true'? true: false; $('input').prop('checked', test || false); }); $('input').on('change', function() { localstorage.input = $(this).is(':checked'); console.log($(this).is(':checked')); });
$('input')
matches all inputs. give more specific selector (preferably id
of input want remember.