“Grup radio bereaksi” Kode Jawaban

Tombol Radio di React

  const [gender,setgender]=useState()

 const handlegender=(e)=>{
    setgender(e.target.value)
  }
 

 
 <form>
        
        <div>
          <label>Gender</label>
          <input type="radio" name="gender" value="male" onChange={handlegender} />
          Male
          <input type="radio" name="gender" value="Female" onChange={handlegender}/>
          Female
        </div>
      </form>
Developer FS

reactjs tombol radio onchange

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  handleChange = e => {
    const { name, value } = e.target;

    this.setState({
      [name]: value
    });
  };

  render() {
    return (
      <div className="radio-buttons">
        Windows
        <input
          id="windows"
          value="windows"
          name="platform"
          type="radio"
          onChange={this.handleChange}
        />
        Mac
        <input
          id="mac"
          value="mac"
          name="platform"
          type="radio"
          onChange={this.handleChange}
        />
        Linux
        <input
          id="linux"
          value="linux"
          name="platform"
          type="radio"
          onChange={this.handleChange}
        />
      </div>
    );
  }
}

Grup radio bereaksi

class App extends React.Component {
  
  setGender(event) {
    console.log(event.target.value);
  }
  
  render() {
    return ( 
      <div onChange={this.setGender.bind(this)}>
        <input type="radio" value="MALE" name="gender"/> Male
        <input type="radio" value="FEMALE" name="gender"/> Female
      </div>
     )
  }
}

ReactDOM.render(<App/>, document.getElementById('app'));
talhadev

Jawaban yang mirip dengan “Grup radio bereaksi”

Pertanyaan yang mirip dengan “Grup radio bereaksi”

Lebih banyak jawaban terkait untuk “Grup radio bereaksi” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya