MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
document.addEventListener("DOMContentLoaded", function() { | document.addEventListener("DOMContentLoaded", function() { | ||
const | // Get all toggle headers (sections) | ||
const toggleHeaders = document.querySelectorAll('.toggle-header'); | |||
toggleHeaders.forEach(function(header) { | |||
// Add click event listener to each header | |||
header.addEventListener('click', function() { | header.addEventListener('click', function() { | ||
const | // Find the content to toggle (it's the next sibling) | ||
const content = header.nextElementSibling; | |||
// Toggle the visibility of the content | |||
content.style.display = | if (content && content.classList.contains('toggle-content')) { | ||
content.style.display = (content.style.display === 'none' || content.style.display === '') ? 'block' : 'none'; | |||
} | } | ||
}); | }); | ||
}); | }); | ||
}); | }); |
Revision as of 00:59, 14 January 2025
document.addEventListener("DOMContentLoaded", function() { // Get all toggle headers (sections) const toggleHeaders = document.querySelectorAll('.toggle-header'); toggleHeaders.forEach(function(header) { // Add click event listener to each header header.addEventListener('click', function() { // Find the content to toggle (it's the next sibling) const content = header.nextElementSibling; // Toggle the visibility of the content if (content && content.classList.contains('toggle-content')) { content.style.display = (content.style.display === 'none' || content.style.display === '') ? 'block' : 'none'; } }); }); });