1.引入這些檔案:
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicGcq5SZhNjMkBjMyMGOxkTZihjY0IGNyQjY5UmZ1UTMhdzYkNjYy8CX0VmbjN3bvwFdl5mLh5WaoN2cv5yZtl2Yz92Lc9CX6MHc0RHaiojIsJye.jpg)
2.html中先寫入模闆:
<textarea name="contentremark" id="contentremark"></textarea>
3.js:
初始化:
var ue = UE.getEditor('contentremark',{toolbar:[["insertunorderedlist","insertorderedlist","bold","italic"]]});
設定和讀取編輯器的内容:
var ue = UE.getContent();
//對編輯器的操作最好在編輯器ready之後再做
ue.ready(function() {
//設定編輯器的内容
ue.setContent('hello');
//擷取html内容,傳回: <p>hello</p>
var html = ue.getContent();
//擷取純文字内容,傳回: hello
var txt = ue.getContentTxt();
});
4.工具欄的值(以下是與字型相關的):
insertunorderedlist/insertorderedlist 無序清單/有序清單
bold/italic/underline/strikethrough 加粗/斜體/下劃線/中間行線
forecolor/backcolor 字型顔色/背景顔色
justifyleft/justifyright/justifycenter/justifyjustify 居左/右/中對齊 兩端對齊
fontfamily/fontsize/customstyle/paragraph 字型/字型大小/自定義标題/段落格式
轉載于:https://my.oschina.net/u/3950671/blog/2251638