How to make a option to hide the element on the second press?

There is a block by clicking on it the other block changes the property display: none to display: block. Wrote a simple function on click, but hides when pressed again, never figured out how to do tell me, thanks
June 10th 19 at 15:53
2 answers
June 10th 19 at 15:55
Googly toggle
June 10th 19 at 15:57
The logic is simple (it is the basis of the toggle).

var opened = false; // create a Boolean variable flag, which will record the status
var button, content; // the button and the block

button.addEventListener("click", function () {
 if (opened) {
 // if the variable says that the box is opened - close
 opened = false; // writable is closed = "none";
 } else {
 // if the variable recorded in the hidden block - open
 opened = true; // writable open = "block";
}, false);

Find more questions by tags jQuery