window.addEventListener('load', () => { lightWhereiam(); }) function lightWhereiam(){ var menug=''; var menug1=''; document.querySelectorAll('.grid-menu1 .menugornear ul:nth-child(2) li a').forEach(lighted => { var link= window.location.href; var link1= lighted.getAttribute('href'); if(link.includes(link1)){ menug= link1.substring(2,link1.length).substring(0,link1.substring(2,link1.length).indexOf('/')); } }) console.log(menug+'menu dolne'); document.querySelectorAll('.grid-menu1 .menugornear ul:nth-child(2) li:not(ul) a').forEach(lighted1 => { if(lighted1.getAttribute('href').includes(menug)){ // lighted1.style.setProperty('background-color','green', 'important'); lighted1.parentNode.style.setProperty('background-color','green'); lighted1.parentNode.style.setProperty('color','white'); document.querySelectorAll('#'+lighted1.parentNode.id+' li a').forEach(items => { items.removeAttribute('style'); }) } }) }