-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangecolor.js
34 lines (34 loc) · 973 Bytes
/
Changecolor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React,{Component} from "react";
class Changecolor extends Component{
constructor(props){
super(props);
this.state={
color:'#FF0FF0',
}
}
redHandler=()=>{
this.setState({color:'#FF0000'});
}
greenHandler=()=>{
this.setState({color:'#00FF00'});
}
blueHandler=()=>{
this.setState({color:'#0000FF'});
}
render(){
return(
<div>
<h1 style={{color:this.state.color}}>
TextColor
</h1>
<button type="submit" onClick={this.redHandler}>Red</button>
<button type="submit" onClick={this.greenHandler}>Green</button>
<button type="submit" onClick={this.blueHandler}>Blue</button>
</div>
);
}
}
export default Changecolor;