Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button onclick="changeAndStoreText()">Change and store</button>
- <p id="text">Text</p>
- <script>
- function changeAndStoreText(){
- localStorage.setItem('firstScreenText', document.getElementById('text').textContent)
- document.getElementById('text').innerHTML = 'Another text';
- window.onload = function () {
- if (localStorage.getItem('firstScreenText')) document.getElementById('text').innerHTML = localStorage.getItem('firstScreenText');
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment