MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
// Log a message to the console | // Wait for the DOM to be ready | ||
console.log('JavaScript is working!'); | document.addEventListener('DOMContentLoaded', function() { | ||
// Log a message to the console | |||
console.log('JavaScript is working!'); | |||
// Find all elements with class "card" | |||
var cards = document.getElementsByClassName('card'); | |||
// Convert the HTMLCollection to an array | |||
var cardsArray = Array.from(cards); | |||
// Log a message if cards are found | |||
if (cardsArray.length > 0) { | |||
console.log('Found all cards:', cardsArray); | |||
} else { | |||
console.log('No cards found.'); | |||
} | |||
}); |
Revision as of 11:14, 8 January 2024
// Wait for the DOM to be ready document.addEventListener('DOMContentLoaded', function() { // Log a message to the console console.log('JavaScript is working!'); // Find all elements with class "card" var cards = document.getElementsByClassName('card'); // Convert the HTMLCollection to an array var cardsArray = Array.from(cards); // Log a message if cards are found if (cardsArray.length > 0) { console.log('Found all cards:', cardsArray); } else { console.log('No cards found.'); } });