website-risg/templates/app.js

22 lines
659 B
JavaScript
Raw Normal View History

2024-02-17 11:27:54 +01:00
document.addEventListener('DOMContentLoaded', function() {
toggleSummary();
});
function toggleSummary() {
2024-02-17 16:38:58 +01:00
const openBtns = document.querySelectorAll('.open-js');
const closeBtns = document.querySelectorAll('.close-js');
2024-02-17 16:27:15 +01:00
const detailElements = document.querySelectorAll('details');
2024-02-17 11:27:54 +01:00
2024-02-17 16:38:58 +01:00
openBtns.forEach(function(openBtn) {
openBtn.addEventListener('click', function(){
detailElements.forEach((detail) => detail.setAttribute("open", ""));
});
2024-02-17 11:27:54 +01:00
});
2024-02-17 16:38:58 +01:00
closeBtns.forEach(function(closeBtn) {
closeBtn.addEventListener('click', function(){
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
});
2024-02-17 11:27:54 +01:00
});
}