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

141
Views
La clase activa no aparece para las secciones (manipulación DOM)

Los elementos CSS y HTML construyen diferentes secciones de esta página de destino, que estoy manipulando desde el DOM. Estoy creando un código para resaltar la sección actualmente en la ventana gráfica junto con resaltar el elemento de navegación a la vista usando Javascript. Lo hice obteniendo dimensiones a través de getBoundingClientRect() y luego agregué "clase activa" usando classlist. Sin embargo, la sección activa no funciona en mi proyecto. Ya intenté depurar el proyecto.

Cuando me desplazo, una sección a la vista no se resalta.

El repositorio del proyecto se encuentra aquí: https://github.com/Himanshukumar30/Landing-Page

 // Check the section in view function sectionInView () { const position = element.getBoundingClientRect(); return (position.top <= 150 && position.bottom >= 150); } // Set sections as active function activeClass() { for (section of sections) { if (sectionInView(section)) { // Add "active-class" to section in view port section.classList.add("active-class"); } else { // Remove "active-class" from section not in view port section.classList.remove("active-class"); } } } // Function call to show active section in view document.addEventListener("scroll", function() { activeClass(); });

Intenté agregar la clase activa manualmente, todavía no funcionó.

Cuando registro la sección en la consola, da el siguiente error:

 63app.js:32 Uncaught ReferenceError: element is not defined at sectionInView (app.js:32:22) at activeClass (app.js:39:13) at HTMLDocument.<anonymous> (app.js:54:5)
about 4 years ago · Juan Pablo Isaza
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!