0%

jQuery修改UEditor内容

UEditor初始化内容是通过Javascript设置的,如:

<script type="text/plain" id="myEditor"> 初始化内容</script>

但是,如果直接用jQuery的html方法,修改内容后,会发现,编辑器不见了,只显示一段文本。 其实UEditor带了一个setContent方法,可以直接设置内容。

 var editor = new baidu.editor.ui.Editor({
        textarea:'introduction'
    });
    editor.render("myEditor");
    editor.setContent("内容");

同样可以在用jQuery取到内容后用setContent方法设置