How to save data from a form with HTML5 Local Storage?

前端 未结 5 2045
我在风中等你
我在风中等你 2020-11-28 08:23

I have a form that makes logging into a website but not in mine and I want them to be saved form data in my web with HTML5 local storage. But not how. Any idea? My form is t

5条回答
  •  死守一世寂寞
    2020-11-28 08:53

    LocalStorage has a setItem method. You can use it like this:

    var inputEmail= document.getElementById("email");
    localStorage.setItem("email", inputEmail.value);
    

    When you want to get the value, you can do the following:

    var storedValue = localStorage.getItem("email");
    

    It is also possible to store the values on button click, like so:

    
    
    
    

提交回复
热议问题