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
No edit summary Tags: Manual revert Reverted |
No edit summary Tag: Manual revert |
||
| Line 2: | Line 2: | ||
document.body.addEventListener('click', function (e) { | document.body.addEventListener('click', function (e) { | ||
var target = e.target; | var target = e.target; | ||
if ( | // Ensure the clicked element is an <a> inside a <span class="show-div"> | ||
e.preventDefault(); | if (target.tagName.toLowerCase() === 'a' && target.parentNode.className.indexOf('show-div') !== -1) { | ||
var targetId = | e.preventDefault(); // Prevent default anchor behavior | ||
var targetId = target.getAttribute('href').substring(1); // Extract value after '#' | |||
// Hide all divs | // Hide all divs | ||
| Line 16: | Line 15: | ||
} | } | ||
// Show the targeted div | // Show the targeted div by selecting its data-id | ||
var targetDiv = document.querySelector('.content[data-id="' + targetId + '"]'); | var targetDiv = document.querySelector('.content[data-id="' + targetId + '"]'); | ||
if (targetDiv) { | if (targetDiv) { | ||
Revision as of 15:01, 9 February 2025
document.addEventListener('DOMContentLoaded', function () {
document.body.addEventListener('click', function (e) {
var target = e.target;
// Ensure the clicked element is an <a> inside a <span class="show-div">
if (target.tagName.toLowerCase() === 'a' && target.parentNode.className.indexOf('show-div') !== -1) {
e.preventDefault(); // Prevent default anchor behavior
var targetId = target.getAttribute('href').substring(1); // Extract value after '#'
// 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 by selecting its data-id
var targetDiv = document.querySelector('.content[data-id="' + targetId + '"]');
if (targetDiv) {
targetDiv.classList.remove('hidden');
}
}
});
});
