运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Storage key() Method</h1> <p>This example demonstrates how to use the key() method to get the name of a local storage item.</p> <button onclick="myFunction()">Get the name of the first local storage item</button> <p id="demo"></p> <script> function myFunction() { var x = localStorage.key(0); document.getElementById("demo").innerHTML = x; } </script> </body> </html>