Skip to content Skip to sidebar Skip to footer

Keeping Js Changes On Dom After Refresh

So, I have this weird thing going on in my test site, where I have every 'link' (be it menu,button, or anything) to show/hide divs instead of loading pages. Pretty basic right? Exc

Solution 1:

You can use the following syntax:

Save data:

sessionStorage.setItem('key', 'value');

Retrieve data:

vardata = sessionStorage.getItem('key');

More info and examples: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

The same goes with localStorage, but with the persistance differences you already found

Solution 2:

I hope my solution will help you: If you want to keep your JS changes, you need to save them to database using AJAX and also change page architecture and logic to use data from database. After that, even if you reload page you will keep all your changes.

Post a Comment for "Keeping Js Changes On Dom After Refresh"