reactjs - Get the value of checkbox using ref in React -


is there way value of checkbox using ref in react. normal way return value "on" me.

var myform = react.createclass({     save: function(){         console.log(this.refs.check_me.value);     },      render: function(){         return <div><h1>myform</h1>             <div classname="checkbox">                 <label>                     <input type="checkbox" ref="check_me" /> check me out                 </label>             </div>             <button classname="btn btn-default" onclick={this.save}>submit</button>         </div>     } }); 

for checkbox, use "checked" instead of "value":

var myform = react.createclass({   save: function () {     console.log(this.refs.check_me.checked);   },    render: function () {     return <div><h1>myform</h1>       <div classname="checkbox">         <label>           <input type="checkbox" ref="check_me" /> check me out         </label>       </div>       <button classname="btn btn-default" onclick={this.save}>submit</button>     </div>   } }); 

as result:

enter image description here


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -