1. 程式人生 > >kindeditor獲取內容,清空,設定kindeditor輸入提示資訊

kindeditor獲取內容,清空,設定kindeditor輸入提示資訊

1初始化kindeditor

var clearDefault=true;//是否有預設文字資訊
var editor = KindEditor.create('textarea[name="s_content"]', {
	allowFileManager : true,
	filterMode:true,
	width : '100%',
	height:'291px',
	items:items_simp,
	afterFocus : function(){//獲得焦點 刪除預設文字資訊
		editor.sync('#s_content');
		if(clearDefault){	
		 if(document.getElementById('s_content').value=="<span style=\"color:#999999;\">企業簡介(不少於</span><span style=\"color:#999999;\">600</span><span style=\"color:#999999;\">字)、圖片(不少於一張、 圖片寬不得大於</span><span style=\"color:#999999;\">800px</span><span style=\"color:#999999;\">,高不限)、宣傳視訊可根據企業情況選擇上傳。</span>"){
			KindEditor.html("#s_content","");
	     } 
			clearDefault=false;	
		}
	},
	afterBlur: function(){this.sync();}//失去焦點,同步資訊資料
	uploadJson : '<%=basePath%>/r/plugins/kindeditor/jsp/upload_json.jsp',
    fileManagerJson : '<%=basePath%>/r/plugins/kindeditor/jsp/file_manager_json.jsp'
});

2點選清除預設資訊
點選清除預設資訊
//同步kindeditor至<textarea>內
editor.sync('#s_content');
//清空kindeditor內容
KindEditor.html("#s_content","");
//初始為true 首次點選清除kindeditor內容後 變為false
clearDefault=false
//獲取文字內容使用原生js
document.getElementById('s_content').value