1
我正在創建一個帶有textarea
和Remarkable的降價編輯器。如果文本的長度大於最小值,我只想提交。我怎樣才能像在我的輸出被認爲是文本的實際長度顯着降價。獲取實際文本長度
var CharCounter = React.createClass({
getText : function(){
if(this.props.count < this.props.min)
return (this.props.min - this.props.count) + ' more to go';
else if(this.props.count < this.props.max)
return (this.props.max - this.props.count) + ' left';
else
return 'Done';
},
render : function(){
return(
<p><small>{this.getText()}</small></p>
);
}
});
的問題是,如果我嘗試直接使用文本區域價值。長度包括降價.ie ['*','**']
好吧。現在添加代碼 – peter
太棒了,你還可以添加綁定Remarkable庫的地方嗎? – Pietro
我會說:'render'方法輸出html,然後我將它放在一個div中,並通過jQuery獲取'.text().length'。 – Pietro