Answer the question
In order to leave comments, you need to log in
How to get the text of an element on click in react?
Good evening. Please tell me how can I get the text of the element when clicked, I try like this, but it does not work, but with iteration through forEacth(el => el.onclick = () => el.innerText)) the situation is similar, but there are no errors .
<li onClick={console.log(this.innerText)}>Item 2</li>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question