I'm trying to remove item from localStorage in javasscript but it doesn't work.
It only works manually for the sequence of the following events
Right click --> Inspect element --> Resources --> localStorage --> Right click --> Delete
I tried:
localStorage.clear();
and
localStorage.removeItem(key); // the key is the link of the page and
// the value is the selected word in the page
and both didn't work, I can save item using localStorage.setItem(key, vaule)
and get items from localStorage using localStorage.getItem(key)
but I can't remove them.
what your looking for is this:
deleter void removeItem(DOMString key);
You could implement this like so:
localStorage.removeItem(key)
Everything about local storage can be found here on the W3 html5 spec for web storage.
You may find this document more helpful as it goes into more explanation.
*Local storage is not a finished spec and these could change.
不带()的localStorage.clear当前可在主要浏览器中使用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.