简体   繁体   English

无法使用 javascript 获取 ckeditor textarea 的 textarea 值

[英]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.当我使用 CKEditor 时,我无法获得textarea的值。 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时,我使用 Ajax 表单提交,然后将值提交到数据库没有问题,但是当我使用 CKEditor 时,数据提交没有textarea值。

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

the above is the textarea上面是textarea

CKEDITOR.replace( 'discription' );

Well, CKEditor got its own way to get textarea value.好吧,CKEditor 有自己的方法来获取textarea值。 So you should do it like this:所以你应该这样做:

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

Or或者

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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