Textarea editor Redactor. Insert value with jQuery

2019-06-18 04:51发布

问题:

Have field textarea id="tr" using HTML editor Redactor last version trying to set value of the field exactly haw it is described in API Doc :

$('#tr').redactor('insertText', 'text'); 

or

$('#tr').redactor('insertHtml', 'text');

What am I doing wrong ?

回答1:

Try the set API, which I think is a lower-level version of insertText/insertHtml.

So in your example, it should be:

$('#tr').redactor('set', 'Your text goes here');

Update: In redactor version 10 (and greater), the name of the set method was changed, as documented here:

$('#tr').redactor('code.set', 'Your text goes here');