How can I append text to html source in CKEditor?

后端 未结 4 1681
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 20:42


I use CKEditor in my web-application. By click on one link i appends some text to CKEditor. It works fine. But when I open source tab, i can not append this te

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-15 21:25

    To append HTML at the end you can do this:

    var targetEditor = CKEDITOR.instances.idOfYourTextarea;
    var range = targetEditor.createRange();
    range.moveToElementEditEnd(range.root);
    targetEditor.insertHtml("

    foo

    ", 'html', range);

提交回复
热议问题