Created
May 6, 2018 12:34
-
-
Save vladanyes/606e656e00f20d6fe3a12c06b207a45d to your computer and use it in GitHub Desktop.
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
if (window.localStorage) { | |
var elements = document.querySelectorAll('[name]'); | |
for (var i = 0, length = elements.length; i < length; i++) { | |
(function(element) { | |
var name = element.getAttribute('name'); | |
element.value = localStorage.getItem(name) || ''; | |
element.onkeyup = function() { | |
localStorage.setItem(name, element.value); | |
}; | |
})(elements[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment