LocalStorage storing multiple div hides

Posted by Jesse Toxik on Stack Overflow See other posts from Stack Overflow or by Jesse Toxik
Published on 2012-11-07T16:42:02Z Indexed on 2012/11/07 17:00 UTC
Read the original article Hit count: 294

Filed under:
|
|
|

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 = ''; 
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about div