HTML and CSS Reference
In-Depth Information
Listing 5.5. app.js—Reading data from
localStorage
At this point you're probably wondering how your application is going to read data from
localStorage
when you haven't actually saved anything in the first place. Fear not!
You're going to solve that problem next by creating a function that will save the user's se-
lected settings to
localStorage
.
5.2.2. Saving data to localStorage
Saving the user's settings is relatively easy. Save data in
localStorage
by using its
Web Storage API method
setItem
, passing two arguments: a key and value.