Simple use of localStorage local storage in html5, html5localstorage
When we use local storage for pages, we will talk about local storage today.
1. localStorage. name = "Old Wang"; // localStorage
2. localStorage. setItem ("color", "red"); // The second method for storing local data
3. localStorage. removeItem ("name"); // Delete Local Storage Data
4. localStorage. name // obtain local data
LocalStorage. getItem ("set") // another method for obtaining local data
5 localStorage. key (0) // obtain the value in the name brackets of the previously stored data. It is the same as the value in the array.
6. localStorage. clear () // clear all locally stored data
7. localStorage. setItem ("set1", "{'name': 'lil', 'age': '000000'}") // Save As json format, 1. Saving 2. Convenient Extraction
8. var price = localStorage. getItem ("set1") // obtain the stored local data
Obj = eval ('+ price +') // converts a json string to an object.
Alert (obj. age) // call the value
Code
<! DOCTYPE html>
Storage location
The above section describes the simple use of localStorage local storage in html5. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!