0

I want to capture the clicked checkbox and execute an event.

var TestApp = React.createClass({
     handleChange: function(){
          var handle = this.getDOMNodes(); //gets entire Div. I want just the selected checkbox
     },
     getInitialState: function(){
         selected: ''
     },
     render: function(){
        return(
           <div>
               <input type="checkbox" className="option1" onChange={this.handleChange}/> Option1<br />
               <input type="checkbox" className="option2" onChange={this.handleChange}/>Option2<br />
               <span>{this.props.selected}</span>
          </div>
       );
    }
});

React.render(<TestApp />, document.body);

1 Answer 1

2

Make use of the event object as you normally would:

handleChange: function(event){
  // event.target refers to the DOM element the event originated from
},
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.