I'm using CKEditor in my web app, and I'm at a loss as to how to get the contents of the editor with HTML formatting.
var objEditor = CKEDITOR.instances["sectionTextArea"]; var q = objEditor.getData();
This will get me the text entered in CKEditor, without any markup.
However,
var q = objEditor.getHTML();
will return a null value. What am I doing wrong?
getHTML isn't a method of a CKEditor object, so instead of null you should have a javascript error.
The method defined by the api is getData() if that doesn't work then you have some other problem in your code, try to use an alert to verify the contents at that moment.
just to know that the right method for this is getData()
didn't help me. I did not know how to use it on the CKEditor object. and CKEDITOR.getData()
doesn't work.
this is how getData()
is used on the CKEDITOR object:
CKEDITOR.instances.my_editor.getData()
...where my_editor
is the id of your textarea used for CKEditor.
The opposite of it is setData()
:
CKEDITOR.instances.my_editor.setData("<p>My Text</p>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With