ReactJS-通过OnClick传递ID

时间:2018-10-04 08:18:07

标签: reactjs arrow-functions

我想将

3 个答案:

答案 0 :(得分:3)

您可以使用事件目标new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//mat-list-item[@class='menu-item mat-list-item ng-star-inserted' and @id='kisiler']//mat-label[@class='ng-star-inserted']"))).click();

e.target

答案 1 :(得分:1)

您可以使用update-alternatives --set php=path to your php ,选中handling events

event

<button type="button" id="button1" name="testName" value="abc" onClick={(event)=>this.callFunction(event)}>Click Me !!</button>

<button type="button" id="button1" name="testName" value="abc" onClick={this.callFunction}>Click Me !!</button> 中,您可以调用read事件:

callFunction

答案 2 :(得分:1)

如评论中所述

使用事件获取ID。将事件传递给处理函数,并使用event.target.id

获取ID值
<button type="button" id="button1" name="testName" value="abc" onClick={event => this.callFunction(event)}>Click Me !!</button>

callFunction = (event) => {
   console.log(event.target.id, event.target.value);
}