在reactjs中的嵌套html标签中获取目标值名称
Getting the target value name in nested html tags in reactjs
我想通过e.target
获取<Menu.Item>
div里面的名字
这是代码:
<Menu.Item as="a" value="PG Details" onClick={this.menuClick}>
<Icon name="home" />
PG Details
</Menu.Item>
还有,这里是 onClick 函数
menuClick = e => console.log(e.target.value);
我想从事件 e
中获取 PG Details
请协助
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
我想通过e.target
获取<Menu.Item>
div里面的名字
这是代码:
<Menu.Item as="a" value="PG Details" onClick={this.menuClick}>
<Icon name="home" />
PG Details
</Menu.Item>
还有,这里是 onClick 函数
menuClick = e => console.log(e.target.value);
我想从事件 e
PG Details
请协助
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