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("請輸入。。。。"); }