I build a simple jsfiddle to show the basic functionality for localStorage at https://jsfiddle.net/KoizumiGaho/nL0o45y8/7/ You can enter a text in the inputfield and store it. If you run the jsfiddle again, you can load the text from local storage.
Here is the HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="result" placeholder="Enter something..." />
<button id="save">Save</button>
<button id="load">Load</button>
And here is the Javascript
function supports_html5_storage() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch (e) {
return false;
}
}
if (supports_html5_storage()) {
$('#save').click(function() {
localStorage.setItem("lastname", $("#result").val());
});
$('#load').click(function() {
$("#result").val(localStorage.getItem("lastname"));
});
} else {
// Sorry! No Web Storage support..
alert('No support for local storage!');
}