javascript 如何在CKEDITOR中动态插入文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31718494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to insert text dynamically in CKEDITOR
提问by Goper Leo Zosa
I use plugin CKEDITOR for word editor in my web. Inside the editor I have a table which have two columns . I want to achieve that in the first column if the user input number it will add to (50) and the result automatically appear in the second column. That is very easy using Jquery but it does not work. Tried codes:
我在我的网站中使用插件 CKEDITOR 作为文字编辑器。在编辑器中,我有一个包含两列的表格。如果用户输入的数字将添加到 (50) 并且结果自动出现在第二列中,我想在第一列中实现这一点。使用 Jquery 很容易,但它不起作用。试过的代码:
function insertIntoCkeditor(str){
CKEDITOR.instances['editor1'].insertText(str);
}
but this code insert automatically above the text area of the editor.
但此代码会自动插入编辑器的文本区域上方。
回答by Arun Kumar
Use
利用
setData()
设置数据()
function insertIntoCkeditor(str){
CKEDITOR.instances['editor1'].setData(str);
}
回答by BlueMan
I am using :
我在用 :
function InsertHTML(HTML)
{
CKEDITOR.instances['editor1'].insertHtml(HTML);
}
and it works fine. ;)
它工作正常。;)
回答by Mari Selvan
CKEDITOR.instance['editor1'].insertElement(str);
It will be insert text in cursor position
它将在光标位置插入文本