Skip to main content

How to Set data to localstorage in javascript

You can set data by specifying the key and value to localStorage.setItem() method in javascript.

  • Set data to localstorage in javascript

    <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.

  • Back to code snippet queries related javascript