Theo/common.js: Unterschied zwischen den Versionen
Aus exmediawiki
Theo (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Theo (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
document.addEventListener('DOMContentLoaded', function() { | |||
// Get all toggle buttons | |||
// | const toggleButtons = document.querySelectorAll('.toggle-button'); | ||
const contentSections = document.querySelectorAll('.content-section'); | |||
let currentlyOpen = null; | |||
toggleButtons.forEach(function(button) { | |||
button.addEventListener('click', function() { | |||
const targetId = this.getAttribute('data-target'); | |||
const targetContent = document.getElementById(targetId); | |||
// If clicking the same button that's already open, close it | |||
if (currentlyOpen === targetId) { | |||
targetContent.style.display = 'none'; | |||
currentlyOpen = null; | |||
return; | |||
} | |||
// Hide all content sections | |||
contentSections.forEach(function(section) { | |||
section.style.display = 'none'; | |||
}); | |||
// Show the target content | |||
targetContent.style.display = 'block'; | |||
currentlyOpen = targetId; | |||
}); | }); | ||
}); | |||
} | |||
}); | }); | ||
Version vom 26. Mai 2025, 13:41 Uhr
document.addEventListener('DOMContentLoaded', function() {
// Get all toggle buttons
const toggleButtons = document.querySelectorAll('.toggle-button');
const contentSections = document.querySelectorAll('.content-section');
let currentlyOpen = null;
toggleButtons.forEach(function(button) {
button.addEventListener('click', function() {
const targetId = this.getAttribute('data-target');
const targetContent = document.getElementById(targetId);
// If clicking the same button that's already open, close it
if (currentlyOpen === targetId) {
targetContent.style.display = 'none';
currentlyOpen = null;
return;
}
// Hide all content sections
contentSections.forEach(function(section) {
section.style.display = 'none';
});
// Show the target content
targetContent.style.display = 'block';
currentlyOpen = targetId;
});
});
});