Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda