For the latest updates, send a blank email to our SUBSCRIPTION ADDRESS
HEADLINES | CLASSIFIED | SPORTS | FORUM | BUSINESS | ENTERTAINMENT
Vol. 1, Issue 9
The News Organ of Liberty City
Thursday October 18th, 2001
" Yesterday's News Today "
MediaWiki:Gadget-tabs.js: Difference between revisions
From Liberty Tree
Jump to navigationJump to search
(Created page with "document.addEventListener('DOMContentLoaded', function () { document.body.addEventListener('click', function (e) { var target = e.target; // Check if the clicked element has class "show-div" if (target.className.indexOf('show-div') !== -1) { e.preventDefault(); var targetId = target.getAttribute('data-target'); // Hide all divs var...") |
No edit summary |
||
Line 2: | Line 2: | ||
document.body.addEventListener('click', function (e) { | document.body.addEventListener('click', function (e) { | ||
var target = e.target; | var target = e.target; | ||
// Ensure we get the parent <span> that contains class "show-div" | |||
var parentSpan = target.closest ? target.closest('.show-div') : null; | |||
if (parentSpan) { | |||
e.preventDefault(); | e.preventDefault(); | ||
var targetId = | var targetId = parentSpan.getAttribute('data-target'); | ||
// Hide all divs | // Hide all divs |
Revision as of 14:28, 9 February 2025
document.addEventListener('DOMContentLoaded', function () { document.body.addEventListener('click', function (e) { var target = e.target; // Ensure we get the parent <span> that contains class "show-div" var parentSpan = target.closest ? target.closest('.show-div') : null; if (parentSpan) { e.preventDefault(); var targetId = parentSpan.getAttribute('data-target'); // Hide all divs var contentDivs = document.querySelectorAll('.content'); for (var i = 0; i < contentDivs.length; i++) { contentDivs[i].classList.add('hidden'); } // Show the targeted div var targetDiv = document.querySelector('.content[data-id="' + targetId + '"]'); if (targetDiv) { targetDiv.classList.remove('hidden'); } } }); });