3 function get(selector) { return document.querySelectorAll(selector); };
4 var menuLinks = get('nav > ul > li > a');
6 for (var i = 0; i < menuLinks.length; i++) {
7 menuLinks[i].onclick = function(){
8 for (var j = 0; j < menuLinks.length; j++) {
9 menuLinks[j ].classList.remove('active');
11 this.classList.add('active');
15 var x = window.location;
16 if ( x.href.indexOf("#") < 0 ) {
17 var anchor = document.getElementsByTagName("section")[0].id
18 window.location = window.location + "#" + anchor;
19 menuLinks[0].classList.add('active');
22 get('a[href="' + window.location.hash + '"]')[0].classList.add('active');