[TASK] add functions open and close
This commit is contained in:
parent
5de6732e7e
commit
200653b74e
@ -3,15 +3,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function toggleSummary() {
|
function toggleSummary() {
|
||||||
const openBtn = document.querySelector('#open-js');
|
const openBtn = document.querySelector('.open-js');
|
||||||
const closeBtn = document.querySelector('#close-js');
|
const closeBtn = document.querySelector('.close-js');
|
||||||
const detailElements = document.querySelectorAll('detail');
|
const detailElements = document.querySelectorAll('details');
|
||||||
|
|
||||||
openBtn.addEventListener('click', function(){
|
openBtn.addEventListener('click', function(){
|
||||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||||
});
|
});
|
||||||
|
|
||||||
closeBtn.addEventListener('click', function(){
|
closeBtn.addEventListener('click', function(){
|
||||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function toggleSummary() {
|
function toggleSummary() {
|
||||||
const openBtn = document.querySelector('#open-js');
|
const openBtn = document.querySelector('.open-js');
|
||||||
const closeBtn = document.querySelector('#close-js');
|
const closeBtn = document.querySelector('.close-js');
|
||||||
const detailElements = document.querySelectorAll('detail');
|
const detailElements = document.querySelectorAll('details');
|
||||||
|
|
||||||
openBtn.addEventListener('click', function(){
|
openBtn.addEventListener('click', function(){
|
||||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||||
});
|
});
|
||||||
|
|
||||||
closeBtn.addEventListener('click', function(){
|
closeBtn.addEventListener('click', function(){
|
||||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user