如何在CKEDITOR中动态插入文本

Gop*_*osa 7 javascript jquery ckeditor ckeditor4.x

我在我的网站上使用插件CKEDITOR进行文字编辑.在编辑器中我有一个有两列的表.我希望在第一列中实现它,如果它将添加到(50)的用户输入数字,并且结果自动出现在第二列中.使用Jquery非常容易,但它不起作用.试用代码:

function insertIntoCkeditor(str){
  CKEDITOR.instances['editor1'].insertText(str);
}
Run Code Online (Sandbox Code Playgroud)

但此代码会自动插入编辑器的文本区域上方.

Aru*_*mar 7

使用

使用setData()

function insertIntoCkeditor(str){
    CKEDITOR.instances['editor1'].setData(str);
}
Run Code Online (Sandbox Code Playgroud)


小智 5

我在用 :

function InsertHTML(HTML)
{
  CKEDITOR.instances['editor1'].insertHtml(HTML);
}
Run Code Online (Sandbox Code Playgroud)

它工作正常。;)