admin管理员组文章数量:1410725
I am the newer for React js. How can i achieve the following logic using react js
Here is two div's and one button. When the user click the button these div should toggle .
I am the newer for React js. How can i achieve the following logic using react js
Here is two div's and one button. When the user click the button these div should toggle .
Share edited Nov 23, 2015 at 20:12 cfprabhu asked Nov 23, 2015 at 20:03 cfprabhucfprabhu 5,3622 gold badges22 silver badges33 bronze badges 1- Stackoverflow stackoverflow./questions/24502898/… should help you – Davet Commented Nov 25, 2015 at 9:28
1 Answer
Reset to default 3You can use states
, like this
var Component = React.createClass({
getInitialState: function () {
return {
outsideText: 'Outside',
insideText: 'Inside'
}
},
handleClick: function () {
this.setState({
outsideText: this.state.insideText,
insideText: this.state.outsideText
})
},
render: function() {
return <div>
<div>
{ this.state.outsideText }
<div>
{ this.state.insideText }
</div>
</div>
<button onClick={this.handleClick}>Change Text</button>
</div>;
}
});
Example
本文标签: javascriptReact js get the value from divStack Overflow
版权声明:本文标题:javascript - React js get the value from div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744807808a2626256.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论