什么';这是CKeditor的getHtml()和getData()之间的区别
对于CKeditor,有两个函数可用于从编辑器获取数据 在下面的示例中,有一个名为什么';这是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()
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
以下是文档: