LocalStorage storing multiple div hides
- by Jesse Toxik
I am using a simple code to hide multiple divs if the link to hide them is clicked.
On one of them I have local storage set-up to remember of the div is hidden or not.
The thing is this. How can I write a code to make local storage remember the hidden state of multiple divs WITHOUT having to put localstorage.setItem for each individual div. Is it possible to store an array with the div ids and their display set to true or false to decide if the page should show them or not?
**********EDITED************
function ShowHide(id) {
if(document.getElementById(id).style.display = '') {
document.getElementById(id).style.display = 'none';
}
else if (document.getElementById(id).style.display = 'none') {
document.getElementById(id).style.display = '';
}