我如何在内容中插入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代码。
你不应该在insertHtml
之后使用editable()
,而是应该使用以下代码:
CKEDITOR.instances['update_content'].insertHtml('<p>This is a new paragraph.</p>');