JSFiddle - React, Tailwind, and code Playground

HTML

<body onload="init()">
  <button onclick="clickHideItems()">Hide items</button>
  <button onclick="clickShowItems()">Show items</button>
  <div class="item" id="div1">1</div>
  <div class="item" id="div2">2</div>
  <div class="item" id="div3">3</div>
</body>

CSS

.item {
  background: silver;
  border: 1px solid black;
}

JavaScript

var div1, div2, div3;
var myGroup;
function clickHideItems() {
  if (!myGroup) return false;
  myGroup.hideAll();
  return true;
}
function clickShowItems() {
  if (!myGroup) return false;
  myGroup.showAll();
  return true;
}
function init() {
  div1 = document.getElementById('div1');
  div2 = document.getElementById('div2');
  div3 = document.getElementById('div3');
  myGroup = [div2, div3];
  myGroup.hideAll = function() {
    this.forEach(function(elem) {
      elem.style.display = 'none';
    });
  };
  myGroup.showAll = function() {
    this.forEach(function(elem) {
      elem.style.display = 'block';
    });
  };
}