HTML and CSS Reference
In-Depth Information
Step 2: Save name and color scheme to localStorage
In order to save the user's name and chosen color scheme, you'll implement a new func-
tion, saveSettings . It will store the user's preferences and change the location
.hash to # list , the Task List view. Add the code from the next listing directly after the
loadSettings function from the previous listing.
Listing 5.6. app.jsā€”Saving data to localStorage
You've now seen how to read and write data using the Web Storage API. Next, we'll show
you how to remove data.
5.2.3. Deleting data from localStorage
In the Settings view of My Tasks, the user has an option to remove all items and settings
from the application. So, you'll need to consider the two data-removal methods in the St-
orage API. The first, removeItem , is useful when you need to delete a single item from
localStorage . The method requires one argument, the key to identify and remove the
Search WWH ::

Custom Search