Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
class list returns empty DomTokens

//when i check if the list item has the className or not it returns false

  sections.forEach(section => {
    const windowHeight =window.innerHeight;
  const sectionTop =section.getBoundingClientRect().top;
  const sectionReveal= 200;
  let current ='';
 
if(sectionTop<windowHeight-sectionReveal){
  section.classList.add('your-active-class');
  current= section.getAttribute('id');
  const myNav =document.querySelectorAll('ul li');
  console.log(myNav[1].classList.contains('menu__link'));
}
else{
  section.classList.remove('your-active-class');
}
});
  };
window.addEventListener('scroll',toggleSection);````
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

document.querySelectorAll('ul li') returns a NodeList. You should iterate all elements of it:

document.querySelectorAll('ul li').forEach(elem => { 
  if (elem.classList.contains('menu__link')) {
    /* do stuff to/with elem */} 
})`.

It may be easier to use document.querySelector('ul li.menu__link').

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!