Mitarbeit willkommen! Bitte schau unter Hilfe:Benutzerkonto oder informiere Dich über Populus.Wiki.

MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Populus DE
Zur Navigation springenZur Suche springen
Zeile 19: Zeile 19:
   
 
var firstA = document.querySelector('#toc a:first-of-type');
 
var firstA = document.querySelector('#toc a:first-of-type');
console.log(firstA);
 
 
if (firstA !== null) {
 
if (firstA !== null) {
 
firstA.classList.add(className);
 
firstA.classList.add(className);

Version vom 16. Juli 2023, 12:14 Uhr

(function () {

const className = "selected";

var thkOnHashChangedListener = function(){
  var prev = document.querySelector('#toc a.' + className);

  if (prev !== null) {
    prev.classList.remove(className);
  }

  var curr = document.querySelector('#toc a[href="' + window.location.hash + '"]');
  if (curr !== null) {
    curr.classList.add(className);
  }
};

window.addEventListener("hashchange", thkOnHashChangedListener);

var firstA = document.querySelector('#toc a:first-of-type');
if (firstA !== null) {
  firstA.classList.add(className);
}

})();