zoukankan      html  css  js  c++  java
  • kindeditor在光标处插入编辑器外的数据

    页面

                   <div class="form-group clearfix">
                                <label class="control-label col-sm-3 col-md-3 col-lg-3 m-from-fon1" for="userName">用户</label>
                                <div class="col-sm-9 col-md-6 col-lg-6">
                                    <input id="userName" name="userName" class="form-control dddd" type="button" value="用户名"/>
                                    <input id="email" name="email" class="form-control dddd" type="button" value="邮箱"/>
                                </div>
                            </div>

    js

    $(document).ready(function () {
      
        buildEditor();
        $(".dddd").on("click",function(){
            //alert($(this).context.name); 拿到name
            var startOffset = contentEditor.cmd.range.startOffset;//kindEditor中当前光标的位置索引值startOffset
            contentEditor.insertHtml('<strong>${'+$(this).context.name+'}</strong>');//js插入指定的HTML内容到光标处。
        });
    });
    
    var contentEditor;
    
    function buildEditor() {
        KindEditor.ready(function (K) {
            contentEditor = K.create('#content', KindEditor.buildOption('/kindeditor/upload.html', 'attachFile'));
        });
    
    
    }
  • 相关阅读:
    常用git命令
    复制文件
    实现斗地主洗牌、发牌、看牌
    线程池实现多线程
    git无法提交问题
    Js中处理日期加减天数
    form详解
    node.js中exports与module.exports的区别
    css的direction属性
    webstorm基础使用
  • 原文地址:https://www.cnblogs.com/xuerong/p/kindeditor.html
Copyright © 2011-2022 走看看