PublishingJS:TheNewSocial: Difference between revisions

From H&D Publishing Wiki
No edit summary
No edit summary
Line 1: Line 1:
console.log( 'Hello from PublishingJS namespace!' )
console.log( 'Hello from PublishingJS namespace!' )


var navLinks = document.querySelectorAll('nav > a');
const nav_links = document.querySelectorAll('.toclevel-1 a');


window.onhashchange = function() {
window.onhashchange = function() {
     for (var i = 0; i < navLinks.length; i++) {
     for (let i = 0; i < nav_links.length; i++) {
         if (navLinks[i].href.match(/(#.*)/)[1] == window.location.hash) {
         if (nav_links[i].href.match(/(#.*)/)[1] == window.location.hash) {
             navLinks[i].className = 'selected';
             nav_links[i].className = 'selected';
         } else {
         } else {
             navLinks[i].className = '';
             nav_links[i].className = '';
         }
         }
     }
     }
};
};

Revision as of 13:56, 19 April 2023

console.log( 'Hello from PublishingJS namespace!' )

const nav_links = document.querySelectorAll('.toclevel-1 a');

window.onhashchange = function() {
    for (let i = 0; i < nav_links.length; i++) {
        if (nav_links[i].href.match(/(#.*)/)[1] == window.location.hash) {
            nav_links[i].className = 'selected';
        } else {
            nav_links[i].className = '';
        }
    }
};