diff --git a/templates/app.js b/templates/app.js index df7f187..cc7dc92 100644 --- a/templates/app.js +++ b/templates/app.js @@ -3,15 +3,19 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleSummary() { - const openBtn = document.querySelector('.open-js'); - const closeBtn = document.querySelector('.close-js'); + const openBtns = document.querySelectorAll('.open-js'); + const closeBtns = document.querySelectorAll('.close-js'); const detailElements = document.querySelectorAll('details'); - openBtn.addEventListener('click', function(){ - detailElements.forEach((detail) => detail.setAttribute("open", "")); + openBtns.forEach(function(openBtn) { + openBtn.addEventListener('click', function(){ + detailElements.forEach((detail) => detail.setAttribute("open", "")); + }); }); - closeBtn.addEventListener('click', function(){ - detailElements.forEach((detail) => detail.removeAttribute("open", "")); + closeBtns.forEach(function(closeBtn) { + closeBtn.addEventListener('click', function(){ + detailElements.forEach((detail) => detail.removeAttribute("open", "")); + }); }); }