UEditor編輯器增加placeholder提示


HTML:

       <div>
              <!-- 加載編輯器的容器 -->
              <div id="editor"  class="fls" style="width:815px;margin-bottom:10px"></div>
       </div>
              <input id="editortext"   type="hidden" />

JS:

//編輯器ID:editor     儲存文本值ID:editortext
UE.Editor.prototype.placeholder = function (justPlainText) { var _editor = this; _editor.addListener("focus", function () { var localHtml = _editor.getPlainTxt(); if ($.trim(localHtml) === $.trim(justPlainText)) { _editor.setContent(""); } }); _editor.addListener("blur", function () { var localHtml = _editor.getContent(); if (!localHtml) { _editor.setContent('<p style="color: #CDCDCD">' + justPlainText + '</p>');//提示語字體灰色 //_editor.setContent(justPlainText);//提示語字體黑色 } }); _editor.ready(function () { _editor.fireEvent("blur"); }); }; //失去焦點,文本為空時,添加 UE.getEditor('編輯器ID').addListener('blur', function () { if ($("#儲存文本值ID").val() == "") { //placeholder內容(只能是文本內容) editor.placeholder("請輸入。。。。"); } }); //實例化編輯器example var editor = UE.getEditor('編輯器ID'); if ($("#儲存文本值ID ").val() == "") { //placeholder內容(只能是文本內容) editor.placeholder("請輸入。。。。"); }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM