website-risg/templates/app.js
Marie Birner 38b93edf20
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 6s
[TASK] refactor js - mutliple button
2024-02-17 16:38:58 +01:00

22 lines
659 B
JavaScript

document.addEventListener('DOMContentLoaded', function() {
toggleSummary();
});
function toggleSummary() {
const openBtns = document.querySelectorAll('.open-js');
const closeBtns = document.querySelectorAll('.close-js');
const detailElements = document.querySelectorAll('details');
openBtns.forEach(function(openBtn) {
openBtn.addEventListener('click', function(){
detailElements.forEach((detail) => detail.setAttribute("open", ""));
});
});
closeBtns.forEach(function(closeBtn) {
closeBtn.addEventListener('click', function(){
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
});
});
}