Advertisement
Guest User

Untitled

a guest
Nov 6th, 2019
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <button onclick="changeAndStoreText()">Change and store</button>
  2. <p id="text">Text</p>
  3. <script>
  4. function changeAndStoreText(){
  5.     localStorage.setItem('firstScreenText', document.getElementById('text').textContent)
  6.     document.getElementById('text').innerHTML = 'Another text';
  7.     window.onload = function () {
  8.     if (localStorage.getItem('firstScreenText')) document.getElementById('text').innerHTML = localStorage.getItem('firstScreenText');
  9.     }
  10. </script>
Advertisement
RAW Paste Data Copied
Advertisement