React - Get text of div on click without refs

前端 未结 4 1855
别跟我提以往
别跟我提以往 2020-12-30 06:05

Is there an example where we can retrieve the value of a React element without the usage of refs? Is that possible?

var Test = React.createClass({

  handle         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 06:20

    If you want to retrieve text, use innerText property, if html – innerHTML.

    Example:

    handleClick: function(e) {
      alert(e.currentTarget.innerHTML);
    }
    

提交回复
热议问题