[TASK] refactor js - mutliple button
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 6s
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 6s
This commit is contained in:
parent
cefbb1d38a
commit
38b93edf20
@ -3,15 +3,19 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function toggleSummary() {
|
function toggleSummary() {
|
||||||
const openBtn = document.querySelector('.open-js');
|
const openBtns = document.querySelectorAll('.open-js');
|
||||||
const closeBtn = document.querySelector('.close-js');
|
const closeBtns = document.querySelectorAll('.close-js');
|
||||||
const detailElements = document.querySelectorAll('details');
|
const detailElements = document.querySelectorAll('details');
|
||||||
|
|
||||||
openBtn.addEventListener('click', function(){
|
openBtns.forEach(function(openBtn) {
|
||||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
openBtn.addEventListener('click', function(){
|
||||||
|
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
closeBtn.addEventListener('click', function(){
|
closeBtns.forEach(function(closeBtn) {
|
||||||
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
closeBtn.addEventListener('click', function(){
|
||||||
|
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user