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

116
Views
Add onClick event to Svg elements using React

I'm trying to integrate this svg tooth chart in my React project : https://codepen.io/johnstuif/pen/JdOXWa?editors=1111 and then add onClick event on every tooth to trigger an alert. i used document.querySelector("g").addEventListener("click", () => alert("clicked")) but it seems that i did something wrong. Does anybody have any idea how to do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

My suggestion is to wrap every tooth in div where you can add onClick event directly in react. Or even better, make it as component!

You're using a powerfull tool that let's you build amazing stuff, no needs for going back to JavaScript dom manipulation when you have react :)

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!