1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 富文本编辑器KindEditor在前端JS的应用

富文本编辑器KindEditor在前端JS的应用

时间:2020-06-23 21:27:46

相关推荐

富文本编辑器KindEditor在前端JS的应用

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报错

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。