Getting the target value name in nested html tags in reactjs

Anurag Chhabra :

I wanted to get the name inside the <Menu.Item> div through e.target Here is the code:

<Menu.Item as="a" value="PG Details" onClick={this.menuClick}>
  <Icon name="home" />
  PG Details
</Menu.Item>

And, here is the onClick function

menuClick = e => console.log(e.target.value);

I want to grab the PG Details from the event e

Please assist

keikai :

Use HTMLElement.innerText

The innerText property of the HTMLElement interface represents the "rendered" text content of a node and its descendants.
As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.

e.target.innerText

enter image description here

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=390382&siteId=1