how to get the value in a tag in react

Solutions on MaxInterview for how to get the value in a tag in react by the best coders in the world

showing results for - "how to get the value in a tag in react"
Clifford
20 Jan 2017
1import React, { Component } from 'react';
2 
3class App extends Component {
4  constructor(props) {
5    super(props);
6    this.handleClick = this.handleClick.bind(this);
7  }
8 
9  handleClick = (event) => {
10      alert(event.target.innerText);    // Click Me
11      alert(event.target.tagName);      // BUTTON
12  }
13 
14  render() {
15    return (
16      <div>
17        <div className="text-center">
18          <button className="btn btn-secondary" onClick={this.handleClick}>
19            Click Me
20          </button>
21        </div>
22      </div>
23    );
24  }
25}
26 
27export default App;