|
|
| (3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
| Zeile 1: |
Zeile 1: |
| document.addEventListener('DOMContentLoaded', function() {
| | alert('JavaScript is working!'); |
| // 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;
| |
| });
| |
| });
| |
| });
| |
alert('JavaScript is working!');