I asked a question yesterday about grouping vars and I got an answer but it only solves half my issue:
I would like to be able to group vars in javascript so I can select a group of div's to show and a group to hide. From previous question I now have:
var elemsById = ['myDIVA','myDIVB','myDIVC'].map(id=>[id,document.getElementById(id)]);
function showThisAndHideRest(showId){
elemsById.forEach(function([id,el]){
el.style.display=id===showId?'block':'none';
});
}
<div id="myDIVA" style="display:none;">blabla 1</div>
<div id="myDIVB" style="display:none;">blabla 2</div>
<div id="myDIVC" style="display:none;">blabla 3</div>
<div onClick="showThisAndHideRest('myDIVB');">Show NEW VERSION</div>
And this works for showing one div and hiding all others. But I cannot make it work to selecting a group of divs to show. This is where I hope some friendly experts can pave the way :-) Thanks for looking. Note: I have a lot of div's (40+ and growing) containing text and css-style - and I would like to group them to show in various combinations on page without reloading the page. Cross-browser-compatibility including slightly older IE's would be preferable :-)