I am using a contentEditable
div and want to get the text inside it when a submit is called. I tried this.refs.textarea.value.trim()
but that doesn't seem to work. My code is as follows in the render return
<div><form onSubmit={this.handleSubmit} id="noter-save-form" method="POST">
<div id="noter-text-area" contentEditable="true" ref="textarea">{value}</div>
and the handleSubmit
function.
handleSubmit: function(e) {
e.preventDefault();
var text = this.refs.textarea.value.trim();
alert(text);
this.saveFile(text);
},
Thanks for the help. I am just looking to replace the text variable with what is actually inside the editable div.
if it's a div it doesn't matter if it's editable and should be this.refs.textarea.innerHTML
and if you just want text this.refs.textarea.innerText
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句