Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
function toggleSection(element) { | function toggleSection(element) { | ||
const content = element.nextElementSibling; | |||
const isExpanded = element.classList.contains('expanded'); | |||
const parentBlock = element.closest('.recipe-block'); | |||
const allContents = parentBlock.querySelectorAll('.section-content'); | |||
const allTitles = parentBlock.querySelectorAll('.section-title'); | |||
allContents.forEach(sec => { | |||
allTitles.forEach( | sec.classList.remove('expanded'); | ||
sec.style.display = 'none'; | |||
}); | |||
allTitles.forEach(t => t.classList.remove('expanded')); | |||
if (!isExpanded) { | if (!isExpanded) { | ||
element.classList.add('expanded'); | |||
content.classList.add('expanded'); | content.classList.add('expanded'); | ||
content.style.display = 'block'; | |||
} | } | ||
} | } | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
const allSections = document.querySelectorAll('.section-content'); | |||
allSections.forEach(section => section.style.display = 'none'); | |||
}); | }); | ||
Версия от 02:58, 17 июня 2025
function toggleSection(element) {
const content = element.nextElementSibling;
const isExpanded = element.classList.contains('expanded');
const parentBlock = element.closest('.recipe-block');
const allContents = parentBlock.querySelectorAll('.section-content');
const allTitles = parentBlock.querySelectorAll('.section-title');
allContents.forEach(sec => {
sec.classList.remove('expanded');
sec.style.display = 'none';
});
allTitles.forEach(t => t.classList.remove('expanded'));
if (!isExpanded) {
element.classList.add('expanded');
content.classList.add('expanded');
content.style.display = 'block';
}
}
document.addEventListener('DOMContentLoaded', function () {
const allSections = document.querySelectorAll('.section-content');
allSections.forEach(section => section.style.display = 'none');
});