How can I build a JavaScript-based curriculum interface for a course?

Trying to create a curriculum UI with JavaScript akin to course platforms. My event listeners malfunction when toggling content in a shared container. See modified code snippet:

const triggerBtns = document.querySelectorAll('.trigger-btn');
const contentBlocks = document.querySelectorAll('.content-block');

triggerBtns.forEach(btn => {
  btn.addEventListener('click', () => {
    if (btn.parentElement === contentBlocks[0].parentElement) {
      btn.style.display = 'inline';
    } else {
      btn.style.display = 'none';
    }
  });
});

In my experience developing similar interfaces, I encountered issues when dynamically associating event listeners with content sections. I addressed this by attaching unique identifiers to each trigger and its corresponding content element, then matching them programmatically. This approach allowed for more precise control over element states during toggling. Additionally, I implemented a debouncing mechanism to avoid potential repeated triggers, which further stabilized the interaction. This methodology simplified the logic in the event handlers and enhanced the overall maintenance of the code.