<div class="simple-collapse">
<a href="#" class="collapse-control">Control</a>
<div class="collapse-content" hidden>Content</div>
</div>
<script>
class SimpleCollapse {
constructor(selector) {
this.elem = document.querySelector(selector);
}
init() {
this.elem.querySelector('a').onclick = this.toggleContent.bind(this);
}
toggleContent() {
this.elem.querySelector('.collapse-content').hidden = !this.elem.querySelector('.collapse-content').hidden
}
}
var obSimpleCollapse = new SimpleCollapse(".simple-collapse");
obSimpleCollapse.init();
</script>