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

198
Vistas
How to change color of div that's selected and others be same?

I have a dynamic array of divs representing numbered lists i.e.

Array.from({length: data.length}).map((item,value)=>(
     <div onClick={()=>sliderRef.current.slickGoTo(index)}></div>
))

I have 2 classes, dot which is a gray color, active which is red. How can change the color of div to red which is clicked/selected and the rest be gray?

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

0

You use React, right? You could write a Component instead of your div that should contain a state variable of isClicked and a function handleClick. HandleClick can then set isClicked to true. Then you can have conditional styling, like:

<div style={{backgroundColor: isClicked ? "red" : "gray"}} />
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