$(function() {
  /** @var {NodeListOf<HTMLElement>} */
  const collapseButtons = document.body.querySelectorAll('.notenuebersicht_belegung');
  collapseButtons.forEach(function(button) {
    if (!button.parentElement && !button.parentElement.parentElement) {
      return;
    }

    /** @var {HTMLElement} */
    const heading = button.parentElement.parentElement;
    if (!heading.classList.contains('row')) {
      return;
    }

    let num = 1;
    heading.addEventListener('click', function(event) {
      if (event.target !== button && event.target.tagName === "DIV") {
        button.click();
      }
    });
  });
});