H
H
Hellas2017-01-28 20:54:39
React
Hellas, 2017-01-28 20:54:39

How to get src and value of child elements when clicking on an element?

<li onClick={this.select}>
  <img src="/uploads/0.png"/>
  <span>Test</span>
</li>

It is necessary when clicking on to liget the values /uploads/0.png​​and Test.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Bobylev, 2017-01-28
@Hellas

In the event handler, iterate in any convenient way e.target.children, where e is the parameter of the handler function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question