logo
Search
showing results for - "get id button clicked react"
Ada
07 Apr 2016
1class Button extends React.Component {
2
3  handleId = (e) => {
4   /*Well if the elements are nested event.target won't always work
5     since it refers to the target that triggers the event in the first place.*/
6    console.log(e.target.id);
7    console.log(e.currentTarget.id);
8  }
9
10  render() {
11    return (
12      <button id="yourID" onClick={this.handleId}>Button</button>
13    );
14  }
15}
16
source
similar questions
get selected value on componentdidmount reactjsreact onpaste get valueget value of input element on button click reactreact first click not workingreact get input value on button click functional componenthow to get value from onclick handler in reacthow to rerender a page in react when the user clicks the back buttoneact functional compoentns update state on clickreactjs pass slug to parameter onclickreact onclick divclick outside react componentreact onclick parameteronclick on fragment reactchange the route on button click react
queries leading to this page
get id of the clicked element javascript reactonclick in react get idreact js get id of clicked elementhow to get id of clicked element in reactonclick get id reactaccessing the id of a button in onclick function reactget id from button reactreact get id of clicked elementget id button clicked react
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue