Suhail Misbah
Suhail Misbah

Reputation: 31

Unable to get the textarea value of a ckeditor textarea with javascript

I'm unable to get the value of the textarea when I use CKEditor. I'm using Ajax form submit when I use the normal textarea then the value gets submitted to the database no issues but when I use CKEditor the data submit without the textarea value.

<textarea class="form-control" placeholder="Add Body" id="discription" name="discription"></textarea>

the above is the textarea

CKEDITOR.replace( 'discription' );

Upvotes: 1

Views: 1167

Answers (1)

SMAKSS
SMAKSS

Reputation: 10510

Well, CKEditor got its own way to get textarea value. So you should do it like this:

// bracket notation
const textareaValue = CKEDITOR.instances['discription'].getData();

Or

// dot notation
const textareaValue = CKEDITOR.instances.discription.getData();

Upvotes: 1

Related Questions