I have a table where I can check a checkbox and it will log all of the contents in the row. There are some search functions and other buttons on the page, so I want to use session storage to be able to keep any checkboxes that are checked, checked, throughout refreshes until the page is closed. I have something from an example I found but it doesnt seem to be working. How could I fix this?
HTML for table column/row with checkboxes:
<td class="ui-widget-content"><input type="checkbox" class="check" name="check" id="checkid"></td>
JavaScript:
$(function(){
var test = sessionStorage.input === 'false'? true: false;
$('input').prop('checked', test || false);
$('input').on('change', function() {
sessionStorage.input = $(this).is(':checked');
console.log($(this).is(':checked'));
});
});
Aucun commentaire:
Enregistrer un commentaire