MediaWiki:Common.js: Difference between revisions
From WikiMSK
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
// Get all the <h2> headings | // Get all the <h2> headings | ||
const headings = document.querySelectorAll('.mw-parser-output h2'); | const headings = document.querySelectorAll('.mw-parser-output h2'); | ||
console.log(headings); | |||
} | } |
Revision as of 08:08, 22 August 2020
/* Any JavaScript here will be loaded for all users on every page load. */
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
docReady(collapseElements);
function collapseElements() {
// Get all the <h2> headings
const headings = document.querySelectorAll('.mw-parser-output h2');
console.log(headings);
}