日韩精品欧美激情国产一区_中文无码精品一区二区三区在线_岛国毛片AV在线无码不卡_亞洲歐美日韓精品在線_使劲操好爽好粗视频在线播放_日韩一区欧美二区_八戒八戒网影院在线观看神马_亚洲怡红院在线色网_av无码不卡亚洲电影_国产麻豆媒体MDX

jquery不能獲得kindeditor編輯器的內(nèi)容?

時(shí)間:2016-12-03 20:56:16 類型:JS/JQUERY
字號(hào):    

問: 在通過Jquery來獲得使用kindeditor編輯器時(shí)的內(nèi)容時(shí), 始終獲得得內(nèi)容是空值, 而通過form表單提交時(shí), 又可以獲得編輯的內(nèi)容, 這是什么原因呢?

答:  因?yàn)樵谑褂胘s/jquery來獲得內(nèi)容時(shí),  沒有同步數(shù)據(jù)到textarea, 使用editor.sync('editor_id')可解決問題;
具體方法如下:

HTML代碼:

 <textarea name="intro" id="editor_id" style="width:700px; height:450px;"></textarea>
         <input type="button" value="提交" />

Jquery代碼如下:

KindEditor.ready(function(K) {
                window.editor = K.create('#editor_id');
				
        });
$(function(){
	$("input[type='button']").click(function(){
        editor.sync('editor_id');//同步數(shù)據(jù)后可以直接取得textarea的value
		var content = $("#editor_id").val();
		if(content=="")alert("內(nèi)容不能為空");
	});
})