« MediaWiki:Commons.js » : différence entre les versions
Apparence
Page créée avec « document.addEventListener('DOMContentLoaded', function () { document.querySelectorAll('.toggle-column').forEach(function (element) { element.addEventListener('click', function () { const target = this.getAttribute('data-target'); document.querySelectorAll('.infobox-column').forEach(function (column) { column.style.display = 'none'; }); document.getElementById(target).style.display = 'block'; }); }); }); » |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
// Add click event listeners to all elements with the class "toggle-column" | |||
document.querySelectorAll('.toggle-column').forEach(function (element) { | document.querySelectorAll('.toggle-column').forEach(function (element) { | ||
element.addEventListener('click', function () { | element.addEventListener('click', function () { | ||
const target = this.getAttribute('data-target'); | const target = this.getAttribute('data-target'); // Get the target column ID | ||
// Hide all columns | |||
document.querySelectorAll('.infobox-column').forEach(function (column) { | document.querySelectorAll('.infobox-column').forEach(function (column) { | ||
column.style.display = 'none'; | column.style.display = 'none'; | ||
}); | }); | ||
// Show the selected column | |||
document.getElementById(target).style.display = 'block'; | document.getElementById(target).style.display = 'block'; | ||
// Update the styling of the active title | |||
document.querySelectorAll('.toggle-column').forEach(function (title) { | |||
title.style.fontWeight = 'normal'; | |||
}); | |||
this.style.fontWeight = 'bold'; | |||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Version du 2 avril 2025 à 11:36
document.addEventListener('DOMContentLoaded', function () {
// Add click event listeners to all elements with the class "toggle-column"
document.querySelectorAll('.toggle-column').forEach(function (element) {
element.addEventListener('click', function () {
const target = this.getAttribute('data-target'); // Get the target column ID
// Hide all columns
document.querySelectorAll('.infobox-column').forEach(function (column) {
column.style.display = 'none';
});
// Show the selected column
document.getElementById(target).style.display = 'block';
// Update the styling of the active title
document.querySelectorAll('.toggle-column').forEach(function (title) {
title.style.fontWeight = 'normal';
});
this.style.fontWeight = 'bold';
});
});
});