You can get data from localStorage by specifying the key to localStorage by getItem() method. Key in localStorage is used to assign the value and get the value.
<script> var modalId = localStorage.getItem('openModal'); </script>
Before getting data from localStorage you have to first set data in localStorage. After that you can get data by passing a key to the localStorage method from any one of the other pages in your browser.
<script> localStorage.setItem('openModal', '#addEventModal'); </script>
You can set data to the localStorage method by specifying the key and value. You have to pass the key as first argument and value as a second argument. You can get the localStorage value by calling the getItem method by specifying the key.
- How to open modal after redirect
- ReferenceError: $ is not defined
- How to add key/value pair to existing form data
- How to crop multiple images with cropper js
- Short-circuits conditionals
- Input type file styling
- Uncaught TypeError: Illegal invocation