在html 5中,localstorage是个不错的东西,在支持localstorage的浏览器中, 能持久化用户表单的输入,即使关掉浏览器,下次重新打开浏览器访问,也能读出其值, 下面给出的例子是使用jquery 在每次表单加载的时候,读localstorage的值,而在表单每次提交时则清楚其值的例子
首先是一个表单:
复制代码 代码如下:
html5 local storage example
html5 local storage example
enquiry form
type of enquiry
please select
general
sales
support
name
email address
message
subscribe to our newsletter
然后是js部分代码:
复制代码 代码如下: