富文本编辑器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报错

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值