Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ronnieoverby/dee7b3cee7693fde0a3a839ca99fd928 to your computer and use it in GitHub Desktop.
Save ronnieoverby/dee7b3cee7693fde0a3a839ca99fd928 to your computer and use it in GitHub Desktop.
<script>
// loop over all "up-down" elements
for(let ud of document.querySelectorAll('span[id$=ud]'))
{
// reflect that it is already expanded
ud.className = 'arrow-up';
// derive the expandable element's id
let id = ud.id.substring(0, ud.id.length - 2);
// collapse everything
toggle(id);
// add click handler for toggling
ud.addEventListener('click', e => {
toggle(id);
});
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment