Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么';这是CKeditor的getHtml()和getData()之间的区别_Ckeditor - Fatal编程技术网

什么';这是CKeditor的getHtml()和getData()之间的区别

什么';这是CKeditor的getHtml()和getData()之间的区别,ckeditor,Ckeditor,对于CKeditor,有两个函数可用于从编辑器获取数据 在下面的示例中,有一个名为p_editor的实例,两个函数的输出相同 var p_editor=CKEDITOR.replace( 'question_editor'); $('#PostQuestion').on('click', function() { console.log( p_editor.getData()); console.log(p_editor.document.getBody().getHtml()

对于CKeditor,有两个函数可用于从编辑器获取数据

在下面的示例中,有一个名为
p_editor
的实例,两个函数的输出相同

var p_editor=CKEDITOR.replace( 'question_editor');
$('#PostQuestion').on('click', function() { 
    console.log( p_editor.getData());
    console.log(p_editor.document.getBody().getHtml());
    console.log(p_editor.document.getBody().getText());
});

所以我想知道这两种函数的区别。

这两种方法对不同类型的对象进行操作:

  • getData()
    CKEDITOR.editor
    类的一个方法

  • getHtml()
    CKEDITOR.dom.element
    类的一个方法

您的代码
p\u编辑器.document.getBody().getHtml()
获取
body
dom元素并对其执行
getHtml()
方法。在本例中,它与整个编辑器的
getData()
相同,但您可以在主体中的另一个dom元素上使用
getHtml()
,并获取其(部分)HTML

以下是文档: