Javascript 获取 CKEditor 内容?- jQuery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4826036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get CKEditor content? - jQuery
提问by ParisNakitaKejser
My CKEditor code is
我的 CKEditor 代码是
window.onload = function()
{
var editor = CKEDITOR.replace( \'big_info\' );
CKEDITOR.config.height = \'330px\';
CKEDITOR.config.toolbar_Full =
[
[\'Source\',\'-\',\'Templates\'],
[\'Maximize\', \'ShowBlocks\'],
[\'Cut\',\'Copy\',\'Paste\',\'PasteText\',\'PasteFromWord\',\'-\',\'SpellChecker\', \'Scayt\'],
[\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
[\'TextColor\',\'BGColor\'],
[\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
\'/\',
[\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'-\'],
[\'Styles\',\'Format\',\'Font\',\'FontSize\'],
[\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
[\'Link\',\'Unlink\',\'Anchor\'],
[\'Image\',\'Flash\',\'Table\',\'HorizontalRule\',\'PageBreak\']
];
CKFinder.SetupCKEditor( editor, { BasePath : \'/javascript/ckfinder/\', RememberLastFolder : false } ) ;
};
I want to take the content of the edit box and send it via JSON from my jQuery script. I can't find how do to it.
我想获取编辑框的内容并通过我的 jQuery 脚本中的 JSON 发送它。我找不到怎么办。
回答by AlfonsoML
This is explained in the integration Guide
这在集成指南中进行了解释
var editor_data = CKEDITOR.instances.big_info.getData();
You can use also the jQuery integration as explained in the CKEditor blogand jQuery integration docs
您还可以使用 jQuery 集成,如CKEditor 博客和jQuery 集成文档中所述
// Get the editor data.
var data = $( 'textarea.editor' ).val();
// Set the editor data.
$( 'textarea.editor' ).val( 'my new content' );