Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get id button clicked react

class Button extends React.Component {

  handleId = (e) => {
   /*Well if the elements are nested event.target won't always work
     since it refers to the target that triggers the event in the first place.*/
    console.log(e.target.id);
    console.log(e.currentTarget.id);
  }

  render() {
    return (
      <button id="yourID" onClick={this.handleId}>Button</button>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery test div exists 
Javascript :: js regx for number validation 
Javascript :: mysql json change key 
Javascript :: add 10 seconds to date javascript 
Javascript :: nodejs increase heap size 
Javascript :: how to loop through an object using lodash 
Javascript :: javascript get first letter of each word 
Javascript :: useHistory goback 
Javascript :: react-native-paper resize switch resize 
Javascript :: adonis andwhere 
Javascript :: nuxt redirect traffic from http to https 
Javascript :: jquery data-toggle modal and tooltip 
Javascript :: react native status bar 
Javascript :: React Native Expo Scrollview Scroll to bottom 
Javascript :: location.reload sweetalert 
Javascript :: javascript excel column letter to number 
Javascript :: js array intersection object 
Javascript :: current year javascript 
Javascript :: jquery event source 
Javascript :: iife arrow function 
Javascript :: nextjs socket.io 
Javascript :: get timezone javascript 
Javascript :: html javascript redirect 
Javascript :: jq get by name 
Javascript :: ng build prod 
Javascript :: check if string contains word nodejs 
Javascript :: react next alias import 
Javascript :: form append other data feild and send through ajax 
Javascript :: onclick event in angular 
Javascript :: graphql float 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =