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

199
Views
how to highlight the selected image?

i want when image is clicked, it shows it selected. i have attached code.

const selectedImageHandler=(event)=>{
     setImage(event.target.currentSrc) //state update
}

.image:focus{
border: 2px solid black;

}

    <div className="row"> 
         data.map((imgData,idx)=>(
           <div className={`col gx-0 gy-0 m-1`} key={idx}>
               <img src={imgData} width="100px" height="100px" className={classes.image} onClick={selectedImageHandler} alt=""/>
           </div>)</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can do something like this

const [selected, setSelected] = useState(null)

.image.selected{
border: 2px solid black;

}

    <div className="row"> 
         data.map((imgData,idx)=>(
           <div className={`col gx-0 gy-0 m-1`} key={idx}>
               <img src={imgData} width="100px" height="100px" className={`${classes.image}${selected === idx? 'selected': ''})} onClick={() => setSelected(idx)} alt=""/>
           </div>)</div>

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!