Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sessionStorage on DOMContentLoaded javascript

nameInput.addEventListener("input", () => {
  sessionStorage.setItem("name", nameInput.value);
});

emailInput.addEventListener("input", () => {
  sessionStorage.setItem("email", emailInput.value);
});

msgInput.addEventListener("input", () => {
  sessionStorage.setItem("message", msgInput.value);
});

document.addEventListener("DOMContentLoaded", () => {
  nameInput.value = sessionStorage.getItem("name");
  emailInput.value = sessionStorage.getItem("email");
  msgInput.value = sessionStorage.getItem("message");
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sessionStorage #DOMContentLoaded #javascript
ADD COMMENT
Topic
Name
8+8 =