admin管理员组

文章数量:1399839

CKEditor 4 not working, getting this error: ([CKEDITOR] Error code: editor-incorrect-element. {element: "body"} ckeditor.js:21 ).

My textarea has an id="body". I have added the script in the header. Everything is as it should be, but still not sure why it doesn't work. Any help is appreciated.

CKEDITOR.replace('body');

CKEditor 4 not working, getting this error: ([CKEDITOR] Error code: editor-incorrect-element. {element: "body"} ckeditor.js:21 ).

My textarea has an id="body". I have added the script in the header. Everything is as it should be, but still not sure why it doesn't work. Any help is appreciated.

CKEDITOR.replace('body');

Share Improve this question asked Jun 17, 2020 at 10:34 BobiBobi 331 gold badge1 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3
<head>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

The editor operates on textarea elements, so create one in your body somewhere:

<textarea id="editor1" name="editor1"></textarea>

Then initialize the editor with the following code after the declaration of your textarea element:-

<script type="text/javascript">
    CKEDITOR.replace( 'editor1' );
</script>

Check if you are calling same id or same class in other element before ckeditor textarea is called.

Eg.

<textarea class="editor_1"  id="editor_1"></textarea>

Check if same id or class is not called in any div above textarea

Eg.

<div class="editor_1" id="editor_1"></div>

本文标签: javascriptCKEditor 4 not working due to error editorincorrectelementStack Overflow