MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 6: | Line 6: | ||
// Find all elements with class "card" | // Find all elements with class "card" | ||
var cards = document.querySelectorAll('.card'); | var cards = document.querySelectorAll('.card'); | ||
// Convert the NodeList to an array for compatibility with older browsers | |||
var cardsArray = Array.prototype.slice.call(cards); | |||
// Log a message if cards are found | // Log a message if cards are found | ||
if ( | if (cardsArray.length > 0) { | ||
console.log('Found all cards:', | console.log('Found all cards:', cardsArray); | ||
} else { | } else { | ||
console.log('No cards found.'); | console.log('No cards found.'); | ||
} | } | ||
}); | }); |
Revision as of 11:13, 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.querySelectorAll('.card'); // Convert the NodeList to an array for compatibility with older browsers var cardsArray = Array.prototype.slice.call(cards); // Log a message if cards are found if (cardsArray.length > 0) { console.log('Found all cards:', cardsArray); } else { console.log('No cards found.'); } });