Created
March 14, 2017 14:23
-
-
Save GiacomoLaw/79b604401cdfd3e6910d68a4c5ebe895 to your computer and use it in GitHub Desktop.
Saves the status of checkboxes to your local disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i, checkboxes = document.querySelectorAll('input[type=checkbox]'); | |
function save() { | |
for (i = 0; i < checkboxes.length; i++) { | |
localStorage.setItem(checkboxes[i].value, checkboxes[i].checked); | |
} | |
} | |
function load_() { | |
for (i = 0; i < checkboxes.length; i++) { | |
checkboxes[i].checked = localStorage.getItem(checkboxes[i].value) === 'true' ? true:false; | |
} | |
} | |
// View the Codepen here: http://codepen.io/GiacomoLaw/pen/evEZMQ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment