[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() {
|
||||
const openBtn = document.querySelector('.open-js');
|
||||
const closeBtn = document.querySelector('.close-js');
|
||||
const openBtns = document.querySelectorAll('.open-js');
|
||||
const closeBtns = document.querySelectorAll('.close-js');
|
||||
const detailElements = document.querySelectorAll('details');
|
||||
|
||||
openBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||
openBtns.forEach(function(openBtn) {
|
||||
openBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||
});
|
||||
});
|
||||
|
||||
closeBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||
closeBtns.forEach(function(closeBtn) {
|
||||
closeBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user