久久久久久AV无码免费看大片,亚洲一区精品人人爽人人躁,国产成人片无码免费爱线观看,亚洲AV成人无码精品网站,为什么晚上搞的时候要盖被子

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

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

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

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

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)容不能為空");
	});
})