Сергей Ракипов,
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.collapse__content {
display: none;
}
.collapse__content_open {
display: block;
}
</style>
</head>
<body>
<div class="collapse">
<div class="collapse__hitarea">Toggle</div>
<div class="collapse__content">Text</div>
</div>
<div class="collapse">
<div class="collapse__hitarea">Toggle</div>
<div class="collapse__content">Text</div>
</div>
<script>
const hitarea = document.querySelectorAll('.collapse__hitarea');
const content = document.querySelectorAll('.collapse__content');
const createCollapse = (button, i) => {
button.addEventListener('click', () => {
content[i].classList.toggle('collapse__content_open')
})
}
hitarea.forEach(createCollapse);
</script>
</body>
</html>