Horje
active state of nav while scrolling Code Example
active state of nav while scrolling
const links = document.querySelectorAll('.links');
const sections = document.querySelectorAll('section');

function changeLinkState() {
  let index = sections.length;

  while(--index && window.scrollY + 50 < sections[index].offsetTop) {}
  
  links.forEach((link) => link.classList.remove('active'));
  links[index].classList.add('active');
}

changeLinkState();
window.addEventListener('scroll', changeLinkState);




Whatever

Related
dynamically change class Code Example dynamically change class Code Example
what is format code Code Example what is format code Code Example
What is the aim of an ARP spoofing attack? Code Example What is the aim of an ARP spoofing attack? Code Example
hbox frame options latex Code Example hbox frame options latex Code Example
where to  plant hespori Code Example where to plant hespori Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7