JSFiddle - React, Tailwind, and code Playground

by mikhailivanko

HTML

<button id="showContent">Показать</button>
<button id="hideContent">Скрыть</button>
<div class="content">Блок 1</div>

<div class="content">Блок 2</div>

<div class="content">Блок 3</div>

JavaScript

var content = document.getElementsByClassName('content');
let show = document.getElementById("showContent");
let hide = document.getElementById("hideContent");

console.log(content)
show.addEventListener("click", () => {
	for(let item of content){
  	item.style.display = "block";
  }
});

hide.addEventListener("click", () => {
	for(let item of content){
  	item.style.display = "none";
  }
});