This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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", ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user