Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
How can I select link and then add onclick event to change other elements styling

I want to know how can I select first,second,third,etc. link from nav. So that I can add onclick event function that changes appearance of Div. Also I have goTo links like index.html#div1. The idea is to click link and the link to navigates us to the div and change it appearance(## Heading ## box-shadow or change background color ), but temporary. You can check some code over here: "https://jsfiddle.net/malle/gwq924fu/1/"

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Have you tried using the JavaScript querySelectorAll() for the links?

You could use something like:

const links = document.querySelectorAll("a");

And to modify its CSS:

links[0].style.backgroundColor = "red";

But all the a elements should have the onClick defined to your function, so you could use if statements to validate what element you would like to modify.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda