javascript - React js get the value from div - Stack Overflow

I am the newer for React js.How can i achieve the following logic using react jsHere is two div's

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
Add a ment  | 

1 Answer 1

Reset to default 3

You 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744807808a4594885.html

相关推荐

  • javascript - React js get the value from div - Stack Overflow

    I am the newer for React js.How can i achieve the following logic using react jsHere is two div's

    2天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信