Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get key from a button in react

const functionCall = (event) => {
    console.log(event.target.getAttribute('a-key'));
}

<button a-key={1} onClick={functionCall}>Press Me</button>

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #key #button #react
ADD COMMENT
Topic
Name
7+9 =