Check checkbox is Checked or Unchecked

Create a new file and give it name index.html. Add the code given below to it:


This example has a limited use as it is. Use it as a reference for your own applications.

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<script src=""></script>
<script src=""></script>
<script src=""></script>

	<div id="react-container"></div>

<script type="text/babel">
var Checkbox = React.createClass({
  getInitialState: function() {
	return {checked: true}
  handleCheck: function() {
	this.setState({checked: !this.state.checked});
  render: function() {
	var msg;
	if (this.state.checked) {
	  msg = "Checked";
	} else {
	  msg = "Un-checked";
	return (
		<input type="checkbox" onChange={this.handleCheck} defaultChecked={this.state.checked}/>
		<p>Checkbox: {msg}</p>

React.render(<Checkbox />,

Most Helpful This Week