on click get the id of the element react code example

Example 1: using this to get name of the clicked element

var clickedBtnID = $(this).attr('id');

Example 2: get element by id in Jquery

$("#YourElementId").val();

Example 3: how to get the value in a tag in react

import React, { Component } from 'react';
 
class App extends Component {
  constructor(props) {
    super(props);
    this.handleClick = this.handleClick.bind(this);
  }
 
  handleClick = (event) => {
      alert(event.target.innerText);    // Click Me
      alert(event.target.tagName);      // BUTTON
  }
 
  render() {
    return (
      
); } } export default App;

Tags:

Misc Example