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
content.style.display = "none";
} else {
// if the variable recorded in the hidden block - open
opened = true; // writable open
content.style.display = "block";
}
}, false);
Find more questions by tags jQuery