kindeditor页面加载添加默认提示

1.在textarea进行操作

<textarea style="width:50%;height:150px;" class="{required:true}" name="question.qstContent" id="qstContent" οnfοcus="if(value=='上传时遇到的特殊公式、表格、符号等 请以图片的形式上传...') {value=''}" οnblur="if(value==''){value='上传时遇到的特殊公式、表格、符号等 请以图片的形式上传...'}">${question.qstContent}</textarea>

2.然后在添加afterFocus和afterBlur事件

//加载编辑器
var editor;
KindEditor.ready(function (K) {
   editor = K.create('textarea[id="qstContent"]', {
      resizeType: 2,
      filterMode: false,//true时过滤HTML代码,false时允许输入任何代码。
      allowPreviewEmoticons: false,
      allowUpload: false,//允许上传
      syncType: 'auto',
      width: '620px',
      minWidth: '10px',
      minHeight: '10px',
      height: '300px',
      newlineTag: 'br',//回车换行br|p
        afterBlur: function () {
            editor.sync();
            console.log(editor.html());
            if (editor.html() == '<br />' || editor.html() == '') {
                editor.html('上传时遇到的特殊公式、表格、符号等 请以图片的形式上传...');
                $("#qstContent").contents().find(".ke-content").css("color","red");
            }
        },
        afterFocus: function () {
            if (editor.html() == '上传时遇到的特殊公式、表格、符号等 请以图片的形式上传...') {
                editor.html('');
                // 输入文字变为黑色
                $("#qstContent").contents().find(".ke-content").css("color","#fff");
            }
        },
      items: ['source','justifyleft', 'justifycenter', 'justifyright',
         'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
         'superscript', 'selectall', 'fontsize', 'forecolor', 'hilitecolor', 'bold', 'underline', 'lineheight'],
      afterChange: function () {
      }
   });
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值