1.引入KindEditor资源包
2.页面引入Js,Css文件
3.html代码:
<tr>
<td class="left">讲师信息</td>
<td>
<textarea id="cot_detail" class="inputTxt"></textarea>
</td>
</tr>
4.Jq代码:
初始化编辑器:
//富文本编辑框
var editor;
function onEditText() {
KindEditor.ready(function (K) {
editor = K.create('#cot_detail', {
resizeType: 0,
width: "80%",
height: "340px",
items: [
'source', '|', 'undo', 'redo', '|', 'preview', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage', 'media',
'insertfile', 'table', 'emoticons', 'baidumap',
'anchor', 'link', 'unlink'
]
});
});
}
绑定值:
editor.html($.Base64Decode(js.Cot_detail));
获取值:
editor.sync();//富文本编辑器同步数据
cot_detail: $.Base64Encode($("#cot_detail").val())
注意:因为富文本编辑器内的字符中可能有换行等,如果不base64可能会json报错