Line 25: | Line 25: | ||
var as = document.getElementById('toc').getElementsByTagName('a'); | var as = document.getElementById('toc').getElementsByTagName('a'); | ||
+ | for (var a of as) { | ||
+ | a.addEventListener('click', function () { | ||
+ | for (var oa of as) { | ||
+ | oa.classList.remove('active'); | ||
+ | } | ||
+ | a.classList.add('active'); | ||
+ | }) | ||
+ | } | ||
+ | |||
+ | |||
document.addEventListener('scroll', function () { | document.addEventListener('scroll', function () { | ||
var activeA = null; | var activeA = null; |
Revision as of 15:52, 6 October 2018