简体   繁体   中英

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' );

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM