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

147
Views
How to find index of array of class elements?

I have a list of svg objects with a certain class name 'test'.

list = document.getElementsByClassName('test')

I want to find the index of an object in the list (e.target) when it is clicked via an event listener. But it's freezing up.

The smallest example that gives an error would be the following:

list.indexOf(list[1])

which should return 1 but doesn't. I think the problem is that getElementsByClassName gives an "array-like" list, not an actual array. But I can't figure out how to get by it.

about 4 years ago · Juan Pablo Isaza
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!