I want to know is it possible to access the next or prev element in ReactJs?I have two inputs by labels a and b.In handlerChecked function I want to check the attribute checked of both inputs.For example I checked a and I want also to check b was checked or not. How can I do it?
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
data: [],
.
.
.
}
}
.
.
.
handlerChecked = (e, elem) => {
let isChecked = e.target.checked
let value = e.target.value
let checknext = e.target.next('input').checked //In this part I want to check the attribute checked of other Input////
}
.
.
.
render() {
return (
<div>
<input type="checkbox" className="" value="0" onChange={this.handlerChecked} /> <label><span>a</span></label>
<input type="checkbox" className="" value="1" onChange={this.handlerChecked} /> <label><span>b</span></label>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('Result'))
stateandpropsto handle VirtualDOM updates. React will make all DOM updates for you.