0
How do I display saved data?
Hi, I would like to know how I would display the user input of their name as when I create a variable to access the data saved as localStorage, I would like to put it in an alert box as like a notification to display that your email has been saved as â..â
1 Answer
+ 3
*/Try on other browser not supported on Sololearn code playground
<! - - html-->
<input type="text" id="email">
<button onClick="saveEmail()">Save email</button>
<script>
function saveEmail(){
//getting input
var email=document.getElementById('email'). value;
//saving value to key userE
localStorage.setItem("userE", email);
//getting saved value with its key
alert("Your email has been saved-"+localStorage.getItem("userE"));
}
</script>