I am wondering how I can set a value in CKEditor
using Javascript?
I have tried the following, but neither of them work...
document.[form name].[textarea name].value=data; $('#textareaID').val(data);
However, both these work without the editor applied. Is there a way I can do this with the editor?
[form name]. [textarea name]. value=data; $('#textareaID'). val(data);
try: var bodyAdd = CKEDITOR. instances['editor1']. getData();
CKEditor is a modern, feature-rich JavaScript text editor with clean UI and perfect UX. Easily customizable to any use case.
You can display data in ckeditor by passing the variable value which you get from the database.
Use the CKEditor method setData()
:
CKEDITOR.instances[**fieldname**].setData(**your data**)
The insertHtml()
and insertText()
methods will insert data into the editor window, adding to whatever is there already.
However, to replace the entire editor content, use setData()
.
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