1 <!-- 1 space -->
2  <!-- tab; 2 space -->
3  <!-- tab; 4 space -->
1const showHideAll =(list)=>{
2 for(var i = 0; i < list.length; i++){
3 list[i].classList.remove('show');
4 list[i].classList.add('hide'); // depending on what you're doing
5 }
6}
7
8window.onload = function() {
9 let innerDiv = document.getElementsByClassName("inner-description");
10 let clicked = document.querySelectorAll('.show-hide-description');
11 clicked.forEach((item, i) => {
12 let clickedId = item.id;
13 document.querySelector(`#${clickedId}`).addEventListener('click',()=>{
14 let clickedIdDescription = document.getElementById(`${clickedId}-description`);
15 if(clickedIdDescription.classList.contains('show')){
16 showHideAll(innerDiv)
17 } else {
18 showHideAll(innerDiv)
19 clickedIdDescription.classList.remove('hide');
20 clickedIdDescription.classList.add('show');
21 }
22 })
23 });
24}
25