From 200653b74e71a9533697fd84279c8acd5d27ab86 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Sat, 17 Feb 2024 16:27:15 +0100 Subject: [PATCH] [TASK] add functions open and close --- output/app.js | 8 ++++---- templates/app.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/output/app.js b/output/app.js index a21c7df..df7f187 100644 --- a/output/app.js +++ b/output/app.js @@ -3,15 +3,15 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleSummary() { - const openBtn = document.querySelector('#open-js'); - const closeBtn = document.querySelector('#close-js'); - const detailElements = document.querySelectorAll('detail'); + const openBtn = document.querySelector('.open-js'); + const closeBtn = document.querySelector('.close-js'); + const detailElements = document.querySelectorAll('details'); openBtn.addEventListener('click', function(){ detailElements.forEach((detail) => detail.setAttribute("open", "")); }); closeBtn.addEventListener('click', function(){ - detailElements.forEach((detail) => detail.setAttribute("open", "")); + detailElements.forEach((detail) => detail.removeAttribute("open", "")); }); } diff --git a/templates/app.js b/templates/app.js index a21c7df..df7f187 100644 --- a/templates/app.js +++ b/templates/app.js @@ -3,15 +3,15 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleSummary() { - const openBtn = document.querySelector('#open-js'); - const closeBtn = document.querySelector('#close-js'); - const detailElements = document.querySelectorAll('detail'); + const openBtn = document.querySelector('.open-js'); + const closeBtn = document.querySelector('.close-js'); + const detailElements = document.querySelectorAll('details'); openBtn.addEventListener('click', function(){ detailElements.forEach((detail) => detail.setAttribute("open", "")); }); closeBtn.addEventListener('click', function(){ - detailElements.forEach((detail) => detail.setAttribute("open", "")); + detailElements.forEach((detail) => detail.removeAttribute("open", "")); }); }