我正在尝试将我在所见即所得编辑器(CK编辑器)中输入的内容传递给JQuery。目前,无论我输入什么,它都是空白的。
HTML:
<textarea type='text' class="ckeditor reply" name='reply'></textarea>
<button type="button" STYLE="align: right;" class="btn btn-info reply_button yGreenButton">Submit Reply</button>JS:
<script>
$(function()
{
$('.reply_button').click(function(){
var reply=$(this).siblings('.reply').val();
});
});
</script>文本区域显示为CKeditor。无论我在CKeditor文本区域中输入什么内容,单击reply_button时提示的当前值都是空的。如何让我输入的实际内容被提醒?
我们非常感谢你的建议。
最好的
发布于 2014-02-16 10:31:48
这是一个CKEditor,你必须使用他们的接口:
var editor = CKEDITOR.replace( '.ckeditor' );
editor.getData();接口文档可以在here上找到。
发布于 2014-02-16 22:01:30
您有两个选择--可以直接使用CKEditor应用编程接口,也可以使用jQuery的CKEditor适配器。
要直接使用CKEditor接口,您需要编辑器实例。您可以使用相关CKEDITOR.instances的id或name或自动生成的名称('editor1‘、'editor2’等)从CKEDITOR.instances对象中获取它。在您的案例中:
var editor = CKEDITOR.instances.reply;
var val = editor.getData();要使用jQuery适配器,您需要在ckeditor.js之后加载adapters/jquery.js文件,然后您可以轻松地检索值:
var val = $( '.ckeditor' ).val();就像你使用普通的textarea一样。在jQuery adapter guide中阅读更多内容并查看CKEditor with jQuery sample。
https://stackoverflow.com/questions/21806329
复制相似问题