如何在CKEDITOR中显示来自html字符串的html预览?

时间:2017-11-09 06:34:22

标签: javascript html ckeditor

JavaScript

var preview = CKEDITOR.document.getById( 'mailViewer' );
     preview.setHtml($('#mail-content').html());

HTML

<span id="mail-content" th:text="${mailReceived.body}" style="display:none;"></span>
<div id="mailViewer"></div>

输出   

我试图在CKEDITOR中设置HTML字符串,但它没有显示HTML预览。如何让它显示html预览

1 个答案:

答案 0 :(得分:0)

如果我理解你的问题是正确的,你应该这样做

CKEDITOR.instances['mailViewer'].setData($('#mail-content').html())