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

196
Views
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 answers
Answer question

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 Report
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!