我如何在内容中插入HTML代码?
此方法未插入html代码:
CKEDITOR.instances['update_content'].setData(info_content);
我尝试过:
CKEDITOR.instances['update_content'].editable().insertHtml('<p>This is a new paragraph.</p>');
但是我得到了错误:
ckeditor.js?v=3:407 Uncaught TypeError: Cannot read property 'checkReadOnly' of undefined
at ckeditor.js?v=3:407
at $.insertHtml (ckeditor.js?v=3:377)
at HTMLButtonElement.<anonymous> (shop:3750)
at HTMLButtonElement.dispatch (jquery.min.js:3)
at HTMLButtonElement.r.handle (jquery.min.js:3)
我需要动态内容,我需要在每次单击按钮时更改CKEditor内容中的HTML代码。
答案 0 :(得分:0)
您不应在insertHtml
之后使用editable()
,而应使用以下代码:
CKEDITOR.instances['update_content'].insertHtml('<p>This is a new paragraph.</p>');