HTML 5 LocalStorage Example
HTML 5 LocalStorage Example with some console logging Kind of simple example
by Ketan Patel
HTML
<section>
<article>
Web Storage example:
<br />
<div id="divDataLocalStorage"></div>
<br />
Value
<input type="text" id="txtboxFooExampleLocalStorage" />
<input type="button" id="btnSaveToLocalStorage" value="Save Text to Local Storage" />
</article>
</section>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
JavaScript
// our array
var movies = ["Reservoir Dogs", "Pulp Fiction", "Jackie Brown",
"Kill Bill", "Death Proof", "Inglourious Basterds"];
// storing our array as a string
localStorage.setItem("quentinTarantino", JSON.stringify(movies));
// retrieving our data and converting it back into an array
var retrievedData = localStorage.getItem("quentinTarantino");
var movies2 = JSON.parse(retrievedData);
//making sure it still is an array
alert(movies2.length);