clear() 方法删除当前域的所有存储对象项。
句法:
localStorage.clear()
属性值:
无属性值
示例:为当前域设置项、清除和显示。
GeeksforGeeks
HTML DOM Storage clear() Method
Example to demonstrate the use of storage
clear() method to delete all the local
storage items for this domain.
Script to create some local storage items.
Click the button to create the items:
Display Items
Click the button to display all the items:
Remove Items
Click the button to clear the storage:
Display Items Again
Click the button to display all the items:
输出:
支持的浏览器: DOM Local Storage clear()支持的浏览器如下:
- 谷歌浏览器 4.0
- 浏览器 8.0
- 火狐 3.5
- 歌剧 10.5
- Safari 4.0