<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Document</
title
>
</
head
>
<
body
>
<
input
type
=
"text"
id
=
"ipt"
value
=
"0"
>
<
button
id
=
"btn"
>清除缓存</
button
>
</
body
>
</
html
>
<
script
>
var storage = window.localStorage;
if(!storage.getItem("num")){
storage.setItem("num",-1);
}
storage.num = parseInt(storage.getItem("num"))+1;
document.getElementById("ipt").value = storage.num;
document.getElementById("btn").onclick = function(){
storage.removeItem("num");
}
</
script
>