首页 > 代码库 > 在线编辑器KindEditor的使用

在线编辑器KindEditor的使用

1、官网下载:点击进入

2、解压后目录说明

├── asp                          asp示例
├── asp.net                    asp.net示例
├── attached                  空文件夹,放置关联文件attached
├── examples                 HTML示例
├── jsp                          java示例
├── kindeditor-all-min.js   全部JS(压缩)
├── kindeditor-all.js        全部JS(未压缩)
├── kindeditor-min.js      仅KindEditor JS(压缩)不包含plugins的JS代码
├── kindeditor.js            仅KindEditor JS(未压缩)不包含plugins的JS
├── lang                        支持语言
├── license.txt               License
├── php                        PHP示例
├── plugins                    KindEditor内部使用的插件
└── themes                   KindEditor主题

3、使用样例

  1. 页面添加textarea标签
    <textarea id="editor_id" name="content" style="width:700px;height:300px;">
    
    </textarea>

     

  2. 在页面添加如下脚本

    <script charset="utf-8" src="/editor/kindeditor.js"></script>
    <script>
            KE.show({
                    id : editor_id
            });
    </script>

     

  3. 获取编辑器的内容
    //取得HTML内容
    html = KE.html(‘editor_id‘);
    
    //同步数据后可以直接取得textarea的value
    KE.sync(‘editor_id‘);
    html = document.getElementById(‘editor_id‘).value;
    html = $(‘#editor_id‘).val(); //jQuery
    
    //设置HTML内容
    KE.html(‘editor_id‘, ‘HTML内容‘);

     

在线编辑器KindEditor的使用