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

231
Views
la clase activa no funciona en la página de índice cuando el índice no tiene en la URL

miaplicacion
├── índice.php
├── aplicaciones.php
├── contacto.php
└── barra lateral.php

en barra lateral.php

 <nav class="side-bar"> <ul> <li> <a href="index.php" class="category" > <i class="fi fi-bs-home"></i> <span>Home</span> </a> </li> <li> <a href="room.php" class="category"> <i class="fi fi-bs-apps"></i> <span>Room</span> </a> </li> <li> <a href="contact.php" class="category"> <i class="fi fi-br-comment-alt"></i> <span>Contact</span> </a> </li> </ul> </nav>

en index.php aplicaciones.php contacto.php

 #more code here <php include('sidebar.php'); #more code here

y uso algo de JavaScript para agregar una clase activa en el enlace de mi página actual

Tenga en cuenta que uso la clase activa para resaltar en el enlace de mi página actual

 const category = document.querySelectorAll('.category'); const activePage =windows.location.href; category.forEach(link =>{ if(link.href === activePage){ link.classList.add('active'); } })

Problema

La clase activa funciona normalmente cuando enlazo a cualquier página como ..\myapp\index.php , pero cuando abro ..\myapp\ Se abrirá automáticamente index.php que hace que mi etiqueta de enlace index.php no esté activa. clase

¿Lo que quiero?

Quiero que sea una clase activa en la página de inicio (index.php) cuando abro ../myapp/ en la url

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!