title: Toggling elements with JavaScript
body: <p>I want to toggle a div element (expand/collapse) when clicked.
  I have many div elements, on click to new element, I want to collapse the previous one and expand the current clicked one.</p>
  
  <p>I tried using static type variable to save the instance of previous div tag and compared with the current selection, but I don't know why is it not working.</p>
  
  <p>Searching about this, I got similar code idea to collapse all div and then expand the current selected only, but I want to just toggle the previous one with new one, not collapse all div and expand the selected (though I would be using it if other way is not possible)</p>
  
  <p>Can it be done using static variables of js?</p>