Remove the the specified local storage item:
localStorage.removeItem("mytime");
Try it Yourself »
The removeItem() method removes the specified Storage Object item.
The removeItem() method belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.
Method | |||||
---|---|---|---|---|---|
removeItem() | 4 | 8 | 3.5 | 4 | 10.5 |
localStorage.removeItem(
keyname)
sessionStorage.removeItem(
keyname)
Parameter | Description |
---|---|
keyname | Required. A String specifying the name of the item you want to remove |
DOM Version: | Web Storage API |
---|---|
Return Value: | No return value |
The same example, but using session storage instead of local storage.
Remove the specified session storage item:
sessionStorage.removeItem("test1");
Try it Yourself »
Web Storage Reference: getItem() Method
Web Storage Reference: setItem() Method
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!